Goal Get overview of disk usage.
Type Sofware measure (Numeric values (software measures) about the database)
License MIT License
Data Source system catalog only
SQL Query
WITH database_size AS (SELECT pg_database_size(current_database()) AS database_total_size),
index_size AS (SELECT Sum(pg_total_relation_size(c.oid)) AS index_total_size
FROM pg_class c
WHERE c.relkind IN ('i','I'))
SELECT pg_size_pretty(database_total_size) AS database_total_size, 
pg_size_pretty(index_total_size) AS index_total_size,
Round(index_total_size*100/database_total_size, 1)  AS percentage_of_index_size_from_total_size
FROM database_size, index_size;

Collections

This query belongs to the following collections:

NameDescription
Find problems by overviewQueries that results point to different aspects of database that might have problems. A human reviewer has to decide based on the results as to whether there are problems or not .
Categories

This query is classified under the following categories:

NameDescription
Data at the database physical levelQueries of this category provide information about the disk usage.