Postgres 9.5 introduced a new feature related to this issue: timestamping .
You just need to activate track_commit_timestamp in postgresql.conf (and restart!) In order to start tracking commit commit marks. Then you can request:
SELECT * FROM tbl WHERE pg_xact_commit_timestamp(xmin) >= '2015-11-26 18:00:00+01';
Read the βLock Timestampβ chapter on the Wiki Postgres.
Related utility functions in the manual .
Function volatility is only VOLATILE , because transaction identifiers ( xid ) can wrap around each definition. Thus, you cannot create a functional index on it.
You could fake IMMUTABLE volatility in the shell of functions for applications for a limited period of time, but you need to know the consequences. A related case with a lot of explanations:
For many use cases (like yours?) That are only interested in the sequence of commits (and not the absolute time), it would be more efficient to work with xmin directly on bigint "( xmin::text::bigint ) instead of fixing timestamps.
(Now offering bigint instead, if integer : xid is an unsigned integer that doesn't fit in the signed integer in the upper half.)
Again, be aware of the limitations due to a possible xid bypass. Read on ...
For the same reason, commit marks are not stored indefinitely . For small and medium sized databases, xid wraparound almost never happens - but it will end up if the cluster lives long enough. For more information, see the Transaction Failure Prevention chapter in the manual.
source share