Re: Discovering time of last database write

From: Scott Marlowe <smarlowe(at)g2switchworks(dot)com>
To: Andy Dale <andy(dot)dale(at)gmail(dot)com>
Cc: pgsql general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Discovering time of last database write
Date: 2007-01-08 16:19:23
Message-ID: 1168273163.20602.5.camel@state.g2switchworks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 2007-01-08 at 02:22, Andy Dale wrote:
> Hi,
>
> Sorry for the slight delay in my response.
>
> I am using 3 PostgreSQL databases and writing to them using an SQL
> proxy. These databases have a high write volume. On rebooting all 3
> servers for OS/Software updates, i would like to figure out which was
> the last written to DB (this is assuming the DB/Servers are not all
> taken down at the same time), the times are kept in sync with NTP.
>
> I imagine it is possible to get this behaviour with after triggers,
> but this means i have to attach the same trigger to each table ??

Hmmmm. Still not completely clear on what exactly you're doing, but I
think I am getting an idea.

You could set each table to have a field for a timestamp, and build a
simple rule / trigger that updates it with the current time stamp for
every row as it's inserted / updated. Then you could select
max(timestampcolumn) from a table to see which db had the latest
version.

I still think there might be a better solution to your problem. Can we
get a more generic overview of what you're trying to do. The 10,000
foot high view, so to speak.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bart McFarling 2007-01-08 16:21:38 Sorting
Previous Message Alvaro Herrera 2007-01-08 16:12:00 Re: doubts