Azure PGSQL Flexible Server storage used calculation

Paul Hernandez 686 Reputation points Microsoft Employee
2023-05-25T14:37:26.97+00:00

Hi everyone, 

I'm trying to determine how the total storage used is calculated in the Azure Monitor for a PostgreSQL Flexible Server.

  • I provisioned a PGSQL Flexible server with 32GB capacity.
  • I only have created a sample database which ocupies around 50MB. I calculated this using
select 
pg_size_pretty(
pg_database_size('zoodb')
)
  • I also estimate the size of the WAL files using:
select pg_size_pretty(sum(size)) as WAL_SIZE
from pg_ls_waldir()
where 
name not in
(
    select split_part(name, '.done', 1) as name
    from pg_ls_waldir()
    where name like '%.done'
)
and 
name not like '%.done';
  • The result is 64MB, which is already bigger than the data files (first thing I would like to understand)
  • I checked in the Azure Monitor, and the metric average "Storage used" is almost 600MB.

User's image

How is that possible?

According to the documentation "The storage is used for the database files, temporary files, transaction logs, and the PostgreSQL server logs".

 I would like to know how can I calculate this using SQL, since Flexible Server is managed by Azure and I don't have access to the file system. The other question is which maintenance measure I can take in order to keep enough empty space.

Thanks in advance for your support 🙂

Best regards,

Paul

Azure Database for PostgreSQL
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.