Show WAL size and current LSN
PostgreSQLWAL & CheckpointCommand
SELECT pg_current_wal_lsn() AS current_lsn, pg_walfile_name(pg_current_wal_lsn()) AS current_wal_file, pg_size_pretty(sum(size)) AS wal_dir_size FROM pg_ls_waldir();What it does
Returns the current WAL LSN, the name of the WAL file being written and the total size of the pg_wal directory.
When to use it
To monitor WAL accumulation, disk usage and checkpoint spacing.
Caution
pg_ls_waldir and pg_walfile_name are available in PostgreSQL 10+; access may require the pg_monitor role.