pg_dbsm
pg_dbsm · track database size
Overview
Usage
Sources:
pg_dbsm 0.0.1 is a background-worker extension that periodically records the size of every database in the cluster. The worker connects to one configured database, creates an unqualified dbsm table there, and appends each database name, collection timestamp, total size, and size increment.
Configure the worker
Restart PostgreSQL after adding pg_dbsm to shared_preload_libraries. dbsm.database selects the storage database and defaults to postgres; dbsm.naptime is the collection interval in seconds and defaults to 86400. Then inspect the worker-created table in that database:
Ownership and failure behavior
The version 0.0.1 installation SQL is effectively empty: CREATE EXTENSION neither registers the background worker nor creates or owns the dbsm table. Preloading the library is what registers the worker, and the worker creates the table and index. Consequently, dropping the extension does not stop a still-preloaded library or clean up those objects.
The first row for each database has a null incsize, not zero: the source tests m.datsize = NULL, which can never be true, and then subtracts the missing previous value. Account for that when reporting growth.
The source configures the worker not to restart automatically after failure. Monitor its process and PostgreSQL log, protect the central table, and define retention because it grows indefinitely. The project has no published modern compatibility matrix; verify this old C background-worker code on the exact PostgreSQL major version before production use.