Friday 31 March 2017

To track last modified commit or get last modified timestamp of table in postgresql

PostgreSQL 9.5 let us to track last modified commit.

1. Check track commit is on or off using the following query

  show track_commit_timestamp;

2. If it return "ON" go to step 3 else modify postgresql.conf

     cd /etc/postgresql/9.5/main/ 

 vi postgresql.conf

      Modification

track_commit_timestamp = off

          to

track_commit_timestamp = on

    Reboot the system
    Repeat step 1.

3. Use the following query to track last commit      

SELECT pg_xact_commit_timestamp(xmin), * FROM  YOUR_TABLE_NAME;

SELECT pg_xact_commit_timestamp(xmin), * FROM YOUR_TABLE_NAME where COLUMN_NAME=VALUE;

     

No comments:

Post a Comment