Re: Discovering time of last database write

From: "Andy Dale" <andy(dot)dale(at)gmail(dot)com>
To: "Scott Marlowe" <smarlowe(at)g2switchworks(dot)com>
Cc: "Bruno Wolff III" <bruno(at)wolff(dot)to>, "pgsql general" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Discovering time of last database write
Date: 2007-01-08 16:42:42
Message-ID: faa313130701080842i273cd91ey672f52259297e0df@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I am still not so certain about adding a timestamp column to each table, as
within a few months the table will be quite big. My current thinking is to
have a trigger per table that overwrties a single value in a single utility
table after every write, this will be far quicker to select when working
with large tables ??? HA-JDBC does not care about the individual table last
write date/time as it is currently not spphisticated enough to do per table
sync with different masters per table, it just loops through each table in
the first db activated treating it as being the most up to date. So HA-JDBC
(i) just need the last write time of the database on a whole, as this will
hopefully mean it is the most up to date.

Andy

On 08/01/07, Scott Marlowe <smarlowe(at)g2switchworks(dot)com> wrote:
>
> On Mon, 2007-01-08 at 03:26, Andy Dale wrote:
> > Ok.
> >
> > The SQL Proxy i am using (HA-JDBC) has some limitations with regard to
> > getting it's "cluster" back into sync. If ha-jdbc uses the wrong DB
> > (one that has been out of action for a while) as the starting point
> > for the cluster it will then try and delete stuff from the other DB's
> > on their introduction to the cluster.
> >
> > I thought the easiest way to control a complete "cluster" restart
> > would be to extract the last write date and introduce the one with the
> > last write date first, this will make certain the above scenario does
> > not happen.
>
> Sorry, I hadn't seen this post when I wrote my lost one.
>
> Yeah, I think having a timestamp column with a rule so it has the
> current timestamp when written to and then selecting for the max in each
> table would work out. You could probably get fancier, but I'm guessing
> that cluster startup is a pretty rare thing, so it's probably easier to
> write a script that selects all the tablenames from pg_tables (???) in
> your schema and checks for the highest time in each table and selects
> the master from that.
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas F. O'Connell 2007-01-08 16:54:24 Re: More activity in pg_stat_activity
Previous Message John Sidney-Woollett 2007-01-08 16:41:53 Re: Command "connect by prior" in PostgreSQL ?