Re: Why is there no object create date is the catalogs?

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Melvin Davidson <melvin6925(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Why is there no object create date is the catalogs?
Date: 2015-05-12 21:53:25
Message-ID: 55527655.7080908@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 05/12/2015 12:51 PM, Melvin Davidson wrote:
>
> Can anyone tell me why there is no "relcreated" column in pg_class to
> track the creation date of an object?

So what date would it track?:

1) The date in the original database?
2) The date the table was restored to another database cluster?
3) The date it was replicated to a standby?
4) The date it went through a DROP TABLE IF EXISTS some_table, CREATE
TABLE some_table cycle?

I could go on. I imagine that most people that want to track that sort
of thing keep their schema definitions under version control and keep
track of the dates there.

>
> It seems to me it would make sense to have one as it would facilitate
> auditing of when objects are created. In addition, it would also
> facilitate the dropping of objects that have exceeded a certain age.

Now, that just scares me:)

That is often handled through partitioning:
www.postgresql.org/docs/9.4/static/ddl-partitioning.html

Otherwise I am not sure how an object being past a certain date equates
to dropping it?

>
> EG: SELECT 'DELETE TABLE ' || relname || ';'
> FROM pg_class
> WHERE relkind = 'r'
> AND relcreated > current_timestamp - INTERVAL ' 1 year';
>
> Adding that column should be relatively easy and would not break
> backwards compatiblity with previous versions.
> --
> *Melvin Davidson*

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2015-05-12 22:00:54 Re: Why is there no object create date is the catalogs?
Previous Message Alvaro Herrera 2015-05-12 20:14:12 Re: Why is there no object create date is the catalogs?