dbTalk Databases Forums  

Data in table changed?

comp.databases.postgresql.general comp.databases.postgresql.general


Discuss Data in table changed? in the comp.databases.postgresql.general forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Thomas Holmgren
 
Posts: n/a

Default Data in table changed? - 03-02-2004 , 08:04 AM






Hi all,

I have a large number of clients synchronizing with a central database.
The clients update their local data by polling the database for changes
at fixed intervals. I need an efficient way of determining if data in a
table has been changed (either updated, deleted or inserted). Can this
be achieved without scanning the tables using expensive SQL? (my tables
are _big_!) Is there some way to get a "time for last update" for a
specific table? Or something similar I can use?

Thank you

Kind regards,
Thomas Holmgren
Denmark


--
Mvh.
Thomas Holmgren



---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster


Reply With Quote
  #2  
Old   
Stephen Frost
 
Posts: n/a

Default Re: Data in table changed? - 03-02-2004 , 08:11 AM






* Thomas Holmgren (thm (AT) regnecentralen (DOT) dk) wrote:
Quote:
I have a large number of clients synchronizing with a central database.
The clients update their local data by polling the database for changes
at fixed intervals. I need an efficient way of determining if data in a
table has been changed (either updated, deleted or inserted). Can this
be achieved without scanning the tables using expensive SQL? (my tables
are _big_!) Is there some way to get a "time for last update" for a
specific table? Or something similar I can use?
I would guess that you could create a trigger for the tables which
updates a seperate (small) table with the last-changed timestamp.

Stephen

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFARJYlrzgMPqB3kigRAva3AJ9pajjF4f/dXLhazgoSn77G/roE/gCfTC5l
DiQZOEfOL4SEWFRwa9vCKRI=
=6OWO
-----END PGP SIGNATURE-----



Reply With Quote
  #3  
Old   
Shridhar Daithankar
 
Posts: n/a

Default Re: Data in table changed? - 03-02-2004 , 08:28 AM



On Tuesday 02 March 2004 19:34, Thomas Holmgren wrote:
Quote:
Hi all,

I have a large number of clients synchronizing with a central database.
The clients update their local data by polling the database for changes
at fixed intervals. I need an efficient way of determining if data in a
table has been changed (either updated, deleted or inserted). Can this
be achieved without scanning the tables using expensive SQL? (my tables
are _big_!) Is there some way to get a "time for last update" for a
specific table? Or something similar I can use?
If you are syncing your entire database, why don't you look at replication
solutions which would transfer WAL files and perform any required updates..

Check http://gborg.postgresql.org/project/...rojdisplay.php

HTH

Shridhar

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster



Reply With Quote
  #4  
Old   
Karl O. Pinc
 
Posts: n/a

Default Re: Data in table changed? - 03-02-2004 , 08:39 AM




On 2004.03.02 08:04 Thomas Holmgren wrote:

I need an efficient way of determining if data in
Quote:
a
table has been changed (either updated, deleted or inserted). Can this
be achieved without scanning the tables using expensive SQL? (my
tables
are _big_!) Is there some way to get a "time for last update" for a
specific table? Or something similar I can use?
You could always make table of 'last changed' timestamps with
columns of tablename and timestamp. Then a function which takes
the name of the table and updates the last_changed table with
a timestamp is called from a trigger for insert, update, and
delete of each table. The CREATE TRIGGER would pass the name
of the table to the function.

Karl <kop (AT) meme (DOT) com>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend



Reply With Quote
  #5  
Old   
Tom Lane
 
Posts: n/a

Default Re: Data in table changed? - 03-02-2004 , 09:23 AM



"Thomas Holmgren" <thm (AT) regnecentralen (DOT) dk> writes:
Quote:
I have a large number of clients synchronizing with a central database.
The clients update their local data by polling the database for changes
at fixed intervals. I need an efficient way of determining if data in a
table has been changed (either updated, deleted or inserted). Can this
be achieved without scanning the tables using expensive SQL?
Are the clients continuously connected to the database? If so you could
forget the whole polling concept and make it data-driven (the clients
listen for NOTIFY events sent out by updaters).

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.