I have 2 databases: postgres (new) ; tnpm (old). Currently, I need to copy data from [tnpm] to [postgres]. I am able to copy it using:
INSERT INTO ip_cpu_mn(datetime, resource_name, cpu_utilization)
SELECT cpu_mn.datetime,resource_name, cpu_utilization
FROM dblink('host=10.0.32.175 user=postgres password=postgres dbname=TNPM_EXT',
'SELECT datetime, resource_name, cpu_utilization
FROM ext_ip.cpu_mn WHERE datetime =(SELECT MAX (datetime) - interval ''10 minutes'' as maxdate FROM ext_ip.cpu_mn)')
AS cpu_mn( datetime timestamp without time zone,
resource_name character varying(150),
cpu_utilization numeric(6,2))
Weirdly, when I start to verify between these database, the data is inconsistent in new database, seem it loss. The copy process is running using crontab 5 min. How can I avoid this ?