Re: Last modification time - Mailing list pgsql-general

From Doug McNaught
Subject Re: Last modification time
Date
Msg-id 873biqt0aw.fsf@asmodeus.mcnaught.org
Whole thread Raw
In response to Last modification time  (Johan Vromans <jvromans@squirrel.nl>)
Responses Re: Last modification time
List pgsql-general
Johan Vromans <jvromans@squirrel.nl> writes:

> Greetings,
>
> For a big application, I want to generate reports from the database and
> keep these on-line as long as they reflect the actual contents of the
> database. I only want to regenerate the reports when needed, i.e.,
> when the database contents have changed.
>
> I'm sure PostgreSQL can tell me when the last update has been
> COMMITted but until now I haven't been able to find out how. I must
> have used the wrong search terms...
>
> Can anyone tell me how to find the last update time of a database?

There isn't any out-of-the-box way that I know of.

I would put an AFTER trigger on all the tables concerned that inserts
a row into an audit table.  Your report generator can then run
periodically, see if there are any new audit entries, generate
reports, and clean out the audit table (if desired).

Note that the audit table may grow very fast and need vacuuming a lot
if you clean it out.

Audit tables are useful for other things too, if you can afford them.

-Doug

pgsql-general by date:

Previous
From: Johan Vromans
Date:
Subject: Last modification time
Next
From: "Karsten Hilbert"
Date:
Subject: Re: Last modification time