Postgres 9.5 or later
You can enable track_commit_timestamp in postgresql.conf (and restart) to start tracking commit timestamps. Then you can get the timestamp for your xmin . Related answer:
Postgres 9.4 or later
PostgreSQL has no such metadata unless you yourself wrote it down.
You can get some information from the row headers (HeapTupleHeaderData) , in particular from the insert transaction id xmin . It contains the identifier of the transaction into which the row was inserted (required to determine visibility in the PostgreSQL MVCC model). Try (for any table):
SELECT xmin, * FROM tbl LIMIT 10;
Some restrictions apply:
- If the database was unloaded and restored, then, obviously, the information disappeared - all rows are inserted into one transaction.
- If the database is huge / very old / very heavily written, then perhaps it went through a transaction identifier bypass , and the order of numbers in
xmin ambiguous.
But for most databases you should be able to get:
- chronological order of the INSERT
- which rows were inserted together
- when (probably) there was a long period of time between the inserts
However, there is no time.
source share