Hi All,<br><br>I was hoping to get some advice on whats the best way to sync two databases. I have a &#39;main&#39; db and&nbsp; an&nbsp; &#39;regional&#39; db, and they have two identical tables, one that holds data with multi-line geometries and a table that holds data with point geometries. The &#39;region&#39; db is really just a subset of data from the &#39;main&#39; db (the records with geometries that fall within the &quot;region&quot;s predefined boundary).<br>
So for our system to properly sync, I see theres 3 things that must occur:<br><br>1) new records in &#39;region&#39; need to be inserted into &#39;main&#39;<br>2) new records in &#39;main&#39; need to be inserted into &#39;region&#39;<br>
3) update existing records in &#39;region&#39; that were modified in &#39;main&#39;<br><br><br>
My current solution is to first update &#39;main&#39; with any new records
created in &#39;region&#39;, and then delete every record in &#39;region&#39;, and mass
insert all the records back into it (again, only those records with the
proper geometry for the region).<br>
But I&#39;m imagining this might become problematic and inefficient if
we&#39;re only updating 5,000 records and already have millions of records
total in &#39;main&#39; and &#39;region&#39;. Deleting and reinserting everything would become really slow. So I thought there might be some other method of just syncing modified/new data.<br><br>Another idea was to have a &quot;timestamp_modified&quot; column in both tables, allowing us to identify the last time a record was modified in &#39;main&#39;. If that timestamp differs in &#39;region&#39;, that record would be updated.<br>
But is that query to find differing timestamps just as slow as deleting and reinserting everything, since it has to check all the records in both instances?<br><br>Anyway, any ideas would be helpful <br>(maybe I&#39;m missing some obvious syncing options in PostGres)<br>
Thanks,<br><br>- Oliver<br>
<br><br><br>