How to find when PostgreSQL cluster was created (initialized)

One of the questions that someone would logically ask, when was the PostgreSQL cluster instance got created. Unfortunately there is no direct answer for this…I tried to find any database view or command that can retrieve this information but couldn’t.

One of the techniques that can help to answer this question is finding template0 database creation date.

first, check oid for template0 usually its “4” :

postgres=# select oid,datname from pg_database;

after that go to the directory: cd $PGDATA/base

timestamp creation for the directory 4 will indicate the time when this postgresql was built (initialization of the cluster).

that’s one way to find out…if you have another better way please share it in the comments….thanks !

Leave a comment

Design a site like this with WordPress.com
Get started