1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-20 15:22:23 +03:00

Add function pg_xlog_location_diff to help comparisons

Comparing two xlog locations are useful for example when calculating
replication lag.

Euler Taveira de Oliveira, reviewed by Fujii Masao, and some cleanups
from me
This commit is contained in:
Magnus Hagander
2012-03-04 12:15:24 +01:00
parent 0e5e167aae
commit bc5ac36865
5 changed files with 114 additions and 2 deletions

View File

@ -14475,11 +14475,15 @@ SELECT set_config('log_statement_stats', 'off', false);
<indexterm>
<primary>pg_xlogfile_name_offset</primary>
</indexterm>
<indexterm>
<primary>pg_xlog_location_diff</primary>
</indexterm>
<para>
The functions shown in <xref
linkend="functions-admin-backup-table"> assist in making on-line backups.
These functions cannot be executed during recovery.
These functions cannot be executed during recovery (except
<function>pg_xlog_location_diff</function>).
</para>
<table id="functions-admin-backup-table">
@ -14547,6 +14551,13 @@ SELECT set_config('log_statement_stats', 'off', false);
<entry><type>text</>, <type>integer</></entry>
<entry>Convert transaction log location string to file name and decimal byte offset within file</entry>
</row>
<row>
<entry>
<literal><function>pg_xlog_location_diff(<parameter>location</> <type>text</>, <parameter>location</> <type>text</>)</function></literal>
</entry>
<entry><type>numeric</></entry>
<entry>Calculate the difference between two transaction log locations</entry>
</row>
</tbody>
</tgroup>
</table>
@ -14639,6 +14650,13 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
needs to be archived.
</para>
<para>
<function>pg_xlog_location_diff</> calculates the difference in bytes
between two transaction log locations. It can be used with
<structname>pg_stat_replication</structname> or some functions shown in
<xref linkend="functions-admin-backup-table"> to get the replication lag.
</para>
<para>
For details about proper usage of these functions, see
<xref linkend="continuous-archiving">.