Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

chore: adds docs for disk space usage.

Div Aroraa4af144ae2be
diff --git a/apps/reference/docs/guides/platform/disk-usage.mdx b/apps/reference/docs/guides/platform/disk-usage.mdx
new file mode 100644
index 00000000000..7e975faceca
--- /dev/null
+++ b/apps/reference/docs/guides/platform/disk-usage.mdx
@@ -0,0 +1,29 @@
+---
+id: disk-usage
+title: Disk Usage
+description: Database Disk Space usage
+---
+
+# Disk space usage
+
+The database disk space usage, as mentioned on the [Supabase pricing page](https://supabase.com/pricing), refers to the _monthly average disk usage_, as reported by Postgres. This metric gets reported within [your project's billing page](https://app.supabase.com/project/_/settings/billing), and is updated _daily_.
+
+For an instantaneous live view of the DB disk space being used by your project, you can execute in Postgres:
+
+```sql
+SELECT SUM(pg_database_size(pg_database.datname)) / (1024 * 1024) as db_size_mb FROM pg_database;
+```
+
+This value also gets reported within the [database settings page](https://app.supabase.com/project/_/settings/database).
+
+## Vacuuming
+
+:::note
+
+Vacuuming operations can temporarily increase resource utilization, which in turn can adversely impact the observed performance of your project while the maintenance is completed.
+
+:::
+
+Postgres does not immediately reclaim the physical space used by dead tuples (e.g. deleted rows) in the db. Instead, they get internally marked as removed until a ["vacuum" operation](https://www.postgresql.org/docs/current/routine-vacuuming.html) is executed. A common manifestation of this mechanism is that deleting data from your DB can sometimes result in the reported disk usage not immediately decreasing by a commensurate amount.
+
+Supabase projects come with automatic vacuuming enabled, which ensures that these operations are performed regularly, in order to keep the database healthy and performant. However, it can sometimes be necessary to either [fine-tune](https://www.percona.com/blog/2018/08/10/tuning-autovacuum-in-postgresql-and-autovacuum-internals/) [the autovacuum parameters](https://www.enterprisedb.com/blog/postgresql-vacuum-and-analyze-best-practice-tips), or [manually initiate](https://www.postgresql.org/docs/current/sql-vacuum.html) vacuum operations. As an example, running a manual vacuum after deleting large amounts of data from your DB could help reduce the reported disk usage by Postgres.
diff --git a/apps/reference/docs/guides/platform/performance.mdx b/apps/reference/docs/guides/platform/performance.mdx
index e747df44863..18c3f4c86ff 100644
--- a/apps/reference/docs/guides/platform/performance.mdx
+++ b/apps/reference/docs/guides/platform/performance.mdx
@@ -38,6 +38,13 @@ In such a scenario, you can consider:
### Configuring clients to use fewer connections
+:::note
+
+`pg_stat_activity` only exposes information on direct connections to the database. Information on the number of connections to pgbouncer is currently available [via the metrics endpoint](../platform/metrics).
+
+:::
+
+
You can use the [pg_stat_activity](https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-ACTIVITY-VIEW) view to debug which clients are holding open connections on your DB.
Depending on the clients involved, you might be able to configure them to work with fewer connections (e.g. by imposing a limit on the maximum number of connections they're allowed to use), or shift specific workloads to connect via [pgbouncer](/docs/guides/database/connecting-to-postgres#connection-pool) instead. Transient workflows, which can quickly scale up and down in response to traffic (e.g. serverless functions), can especially benefit from using a connection pooler rather than connecting to the DB directly.
diff --git a/apps/reference/nav/_referenceSidebars.js b/apps/reference/nav/_referenceSidebars.js
index 18f272594f5..48f41ad26ed 100644
--- a/apps/reference/nav/_referenceSidebars.js
+++ b/apps/reference/nav/_referenceSidebars.js
@@ -192,6 +192,7 @@ const sidebars = {
'guides/platform/logs',
'guides/platform/metrics',
'going-into-prod',
+ 'guides/platform/disk-usage',
'guides/platform/performance',
'guides/platform/permissions',
],