Contents
pg_ls_logicalsnapdir()
A function providing information about files in pg_logical/snapshots
pg_ls_logicalsnapdir()
is a system function for examining the contents of the directory pg_logical/snapshots
.
pg_ls_logicalsnapdir()
was added in PostgreSQL 15.
Usage
pg_ls_logicalsnapdir () → setof record (name
text
,size
bigint
,modification
timestamp with time zone
)
pg_ls_logicalsnapdir()
returns a list of all normal files in the pg_logical/snapshots
directory together with their size and modification timestamp.
Note that the rows are not returned in any particular order, so it may be useful to add an explicit sort criteria.
pg_ls_logicalsnapdir()
can be executed by superusers, members of the predefined role pg_monitor, or any user granted the EXECUTE
privilege.
Change history
- PostgreSQL 15
- added (commit 1922d7c6)
Examples
Example usage for pg_ls_logicalsnapdir()
:
postgres=# SELECT * FROM pg_ls_logicalsnapdir(); name | size | modification ----------------+------+------------------------ 0-14D02E0.snap | 128 | 2021-11-24 11:14:54+01 0-149D258.snap | 128 | 2021-11-24 11:09:21+01 0-14D0370.snap | 128 | 2021-11-24 11:14:54+01 0-14A54C0.snap | 128 | 2021-11-24 11:12:02+01 0-14CFF88.snap | 140 | 2021-11-24 11:12:18+01 0-14D04B8.snap | 128 | 2021-11-24 11:15:46+01 0-14D0200.snap | 132 | 2021-11-24 11:12:39+01 (7 rows)
An explicit ORDER BY
is required to emit rows in a useful order:
postgres=# SELECT * FROM pg_ls_logicalsnapdir() ORDER BY modification DESC; name | size | modification ----------------+------+------------------------ 0-14D04B8.snap | 128 | 2021-11-24 11:15:46+01 0-14D0370.snap | 128 | 2021-11-24 11:14:54+01 0-14D02E0.snap | 128 | 2021-11-24 11:14:54+01 0-14D0200.snap | 132 | 2021-11-24 11:12:39+01 0-14CFF88.snap | 140 | 2021-11-24 11:12:18+01 0-14A54C0.snap | 128 | 2021-11-24 11:12:02+01 0-149D258.snap | 128 | 2021-11-24 11:09:21+01 (7 rows)
References
- PostgreSQL documentation: Generic File Access Functions