DatabaseMeter

PostgreSQL Learn

Why your PostgreSQL database keeps growing

Database growth is a measurement to explain, not automatically a leak. Start by identifying which bytes grew, compare compatible observations over time, and use workload context before choosing a response.

First identify what grew

pg_database_size measures the PostgreSQL database, while relation functions divide stored objects into table and index components. Those logical measurements are not necessarily the same number shown as provider disk usage.

Different PostgreSQL growth measurements
MeasurementWhat it can showWhat it cannot prove
Database bytesThe current logical size of one database.Which object or workload caused the change.
Table bytesHeap, TOAST, and related table storage reported by the selected size function.How much space is immediately removable from disk.
Index bytesStorage used by a table's indexes.Whether every index is useful or safe to remove.
Provider diskA provider-defined storage measurement.The same scope as pg_database_size; it can include WAL and system data.

Inspect the largest relations and recent churn

This read-only query combines current relation sizes with cumulative row-change counters and estimates. Capture the raw bytes, query time, and statistics window when comparing results.

SELECT
  s.schemaname,
  s.relname AS relation_name,
  pg_table_size(s.relid) AS table_bytes,
  pg_indexes_size(s.relid) AS index_bytes,
  pg_total_relation_size(s.relid) AS total_bytes,
  s.n_tup_ins,
  s.n_tup_upd,
  s.n_tup_del,
  s.n_live_tup AS estimated_live_rows,
  s.n_dead_tup AS estimated_dead_rows,
  s.last_autovacuum
FROM pg_stat_user_tables AS s
ORDER BY total_bytes DESC
LIMIT 50;

Common reasons PostgreSQL grows

  • New application data, retained history, partitions, materialized views, or extension-managed objects add stored bytes.
  • Indexes grow with the table and can grow differently according to indexed values, update patterns, and index type.
  • PostgreSQL updates create new row versions. Vacuum normally makes obsolete space reusable inside the relation rather than returning it to the operating system.
  • Large values can move into TOAST storage that is included by total-relation measurements.
  • Write-ahead log generation and retention can increase provider disk consumption without appearing in pg_database_size.

Why deleting rows may not shrink the file

Standard VACUUM removes obsolete row versions from normal use and makes their space available for future writes. It generally does not return that space to the operating system, so a stable file size after deletes can be expected.

Provider disk is a separate scope

Supabase documents database size, WAL, and system files as separate parts of disk usage. Neon separates compute from durable storage and processes WAL through its Safekeeper and Pageserver architecture. Those models are different, so do not infer provider storage or billing from a logical database-size function alone.

Common misleading interpretations

  • Estimated dead rows are not a direct measurement of bloat or recoverable disk space.
  • A growing index is not proof that the index is unused or should be dropped.
  • A larger database is not necessarily unhealthy when retained data and workload have grown.
  • Comparing formatted values without timestamps, raw bytes, and matching scope can produce a false trend.
  • Provider disk growth is not automatically attributable to tables; WAL and provider-managed data may be separate contributors.

When DatabaseMeter can help

Connected monitoring can chart supported logical database-size observations over 7-, 30-, and 90-day windows. The growth calculator can compare two observations and project a threshold using an explicit linear assumption, while the health check can rank bounded table and index footprints.

DatabaseMeter does not infer the cause of growth from size alone and does not equate logical database bytes with a provider bill. Use the relation, maintenance, workload, and provider evidence together.

Definitions and sources

Provider and PostgreSQL statements last reviewed August 29, 2026. Pricing consoles and invoices remain authoritative.