合 PG中的常用系统信息函数
查看当前日志文件lsn位置:
1 2 | select pg_current_xlog_location(); select pg_current_wal_lsn(); |
当前xlog buffer中的insert位置,注意和上面pg_current_xlog_location()的区别:
1 | select pg_current_xlog_insert_location(); |
查看某个lsn对应的日志名:
1 2 | select pg_xlogfile_name(lsn); select pg_walfile_name(lsn); |
查看某个lsn在日志中的偏移量:
1 2 | select pg_xlogfile_name_offset('lsn'); select pg_walfile_name_offset('lsn'); |
查看两个lsn位置的差距:
1 2 | select pg_xlog_location_diff('lsn','lsn'); select pg_wal_lsn_diff('lsn','lsn'); |
查看备库接收到的lsn位置:
1 2 | select pg_last_xlog_receive_location(); select pg_last_wal_receive_lsn(); |
查看备库回放的lsn位置:
1 2 | select pg_last_xlog_relay_location(); select pg_last_xact_replay_timestamp(); |
创建还原点:
1 | select pg_create_restore_point('20201111'); |
查看表的数据文件路径,filenode:
1 2 | select pg_relation_filepath('test'::regclass); select pg_relation_filenode('test'); |
查看表的oid:
1 | select 'test'::regclass::oid; |
查看当前会话pid:
1 | select pg_backend_pid(); |