0

I am new to the PostgreSQL world. I have an experience in administrating Microsoft SQL Server and Oracle databases.

In SQL Server, we are able to find how much space is actually used in pre-allocated log file. I wonder if we can do the same thing in PostgreSQL?

How can we identify which WAL segments are actually full and which WAL segments are empty?

I am currently using PostgreSQL version 10.

0

You can use something like this:

select name > pg_walfile_name(pg_current_wal_lsn()) as "future", sum(size) from pg_ls_waldir() group by 1;

This counts it as not-empty (not future) if even one byte has been written to it, you could elaborate on that using pg_walfile_name_offset if it is important to you but I don't see why it would be.

1
  • That won't show how much of the WAL file was still empty when the WAL segment was switched. Jun 12 at 23:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.