Skip site navigation (1) Skip section navigation (2)

Re: continuous copy/update one table to another

From: John R Pierce <pierce(at)hogranch(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: continuous copy/update one table to another
Date: 2010-03-01 00:29:34
Message-ID: 4B8B0A6E.5050703@hogranch.com (view raw or flat)
Thread:
Lists: pgsql-general
Szymon Guz wrote:
> Different doesn't mean that the id should be greater or lower, rather 
> should be different. I'd rather do something like:

indeed, my code assumed that records were only INSERT'd into table1 and 
never UPDATE or DELETE'd.  my statement -did- have the advantage of 
being fast, at least assuming the id is an index on both tables.   if 
you do update records, you could use a seperate SERIAL/BIGSERIAL field 
for this, which you update on your INSERT's, and use this bigserial for 
your inserts, but you'd need a UPSERT kind of function to handle 
duplicate primary keys.

checking for deletions will be more difficult and more importantly, more 
time consuming as it will likely require multiple full table scans of 
both tables.



In response to

Responses

pgsql-general by date

Next:From: TerryDate: 2010-03-01 00:40:09
Subject: Re: continuous copy/update one table to another
Previous:From: Szymon GuzDate: 2010-02-28 22:40:18
Subject: Re: continuous copy/update one table to another

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group