storage is growing Azure postgre database

Molagara, Bhanu P 20 Reputation points
2023-04-05T10:39:52.7966667+00:00

DB sizes are very less in single digits GB and no replication slots are lagging and no sizes. But storage is growing. How to find which is consuming the storage size.

Azure Database for PostgreSQL
{count} votes

1 answer

Sort by: Most helpful
  1. RahulRandive 10,486 Reputation points Volunteer Moderator
    2023-08-19T15:24:05.3866667+00:00

    Hi,

    The following queries can help you to have insights upon the database storage usage:

    run below query to know each database size

    SELECT pg_database.datname as "database_name", pg_database_size(pg_database.datname)/1024/1024 AS size_in_mb FROM pg_database where datname not like ('%azure%') ORDER by size_in_mb DESC;

    You can get each database temporary files and size using view pg_stat_database 

    SELECT * FROM pg_stat_database;

    At times, replication slots can significantly affect server availability and storage usage. Replication slots retain Postgres WAL logs and relevant system catalogs until they are read by a consumer. If this process fails, unprocessed logs can accumulate and occupy server storage.

    You can check replication slots on server by running:

    select * from pg_replication_slots;

    Analyze the subsequent server parameters that could potentially contribute to the increase in storage usage.

    It's worth noting that you have the option to adjust the retention period for this short-term log storage by using the log_retention_period parameter. The default value is 3 days, and the maximum value allowed is 7 days.

    The common recommendation is to exercise caution when using verbose logging. More information can be found in my colleague blog How to configure Postgres log settings - Microsoft Tech Community

    I hope this is helpful.

    Thank you!

    0 comments No comments

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.