The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Add WAL disk usage to Disk Usage docs (#28248)
Chris Gwilliams315f9634862d
diff --git a/apps/docs/content/guides/platform/database-size.mdx b/apps/docs/content/guides/platform/database-size.mdxindex 3ddc6cb224c..bb9174b5f9f 100644--- a/apps/docs/content/guides/platform/database-size.mdx+++ b/apps/docs/content/guides/platform/database-size.mdx@@ -16,7 +16,7 @@ This SQL query will show the size of all databases in your Postgres cluster:```sqlselect- sum(pg_database_size(pg_database.datname)) / (1024 * 1024) as db_size_mb+ pg_size_pretty(sum(pg_database_size(pg_database.datname)))from pg_database;```@@ -30,6 +30,16 @@ Depending on your billing plan, your database can go into read-only mode which c</Admonition>+### Disk space usage++Your database size is part of the disk usage for your Supabase project, there are many components to Postgres that consume additional disk space. One of the primary components, is the [Write Ahead Log (WAL)](https://www.postgresql.org/docs/current/wal-intro.html). Postgres will store database changes in log files that are cleared away after they are applied to the database. These same files are also used by [Read Replicas](/docs/guides/platform/read-replicas) or other replication methods.++If you would like to determine the size of the WAL files stored on disk, Postgres provides `pg_ls_waldir` as a helper function; the following query can be run:++```sql+select pg_size_pretty(sum(size)) as wal_size from pg_ls_waldir();+```+### Vacuum operationsPostgres does not immediately reclaim the physical space used by dead tuples (i.e., deleted rows) in the DB. They are marked as "removed" until a [vacuum operation](https://www.postgresql.org/docs/current/routine-vacuuming.html) is executed. As a result, deleting data from your database may not immediately reduce the reported disk usage. You can use the [Supabase CLI](https://supabase.com/docs/guides/cli/getting-started) `inspect db bloat` command to view all dead tuples in your database. Alternatively, you can run the [query](https://github.com/supabase/cli/blob/c9cce58025fded16b4c332747f819a44f45c3b83/internal/inspect/bloat/bloat.go#L17) found in the CLI's GitHub repo in the [SQL Editor](https://supabase.com/dashboard/project/_/sql/)