Skip to content

Commit

Permalink
feat: queries related to lsn updated
Browse files Browse the repository at this point in the history
Signed-off-by: Emanuel Calvo <3manuek@gmail.com>
  • Loading branch information
3manuek committed Jun 20, 2023
1 parent 5eb1036 commit df320ce
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
Empty file removed sql/Checkpoints/.gitkeep
Empty file.
5 changes: 2 additions & 3 deletions sql/Checkpoints/checkpoint_distance.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
-- Given the current xlog location, it calculates the size of the current active WAL
-- Source: https://www.cybertec-postgresql.com/en/checkpoint-distance-and-amount-of-wal/
SELECT pg_size_pretty(pg_current_xlog_location() - '0/00000000'::pg_lsn);
-- Amount of generated WALS so far
SELECT pg_size_pretty(pg_current_wal_lsn() - '0/00000000'::pg_lsn);
3 changes: 3 additions & 0 deletions sql/Checkpoints/checkpoint_distance_v9.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Given the current xlog location, it calculates the size of the current active WAL
-- Source: https://www.cybertec-postgresql.com/en/checkpoint-distance-and-amount-of-wal/
SELECT pg_size_pretty(pg_current_xlog_location() - '0/00000000'::pg_lsn);
12 changes: 12 additions & 0 deletions sql/WAL/distance_wals_from_dir.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- Current amount of WALs present in the waldir
WITH oldest_mod_walfile AS (
SELECT (substring(name from 9 for 8) || '/' || substring(name from 17 for 8 ))::pg_lsn as oldest_lsn
FROM pg_ls_waldir()
ORDER BY modification DESC LIMIT 1
)
SELECT pg_size_pretty(pg_wal_lsn_diff( pg_current_wal_lsn(),oldest_lsn))
FROM oldest_mod_walfile;




0 comments on commit df320ce

Please sign in to comment.