Platform

Understanding Database and Disk Size


Disk metrics refer to the storage usage reported by Postgres. These metrics are updated daily. As you read through this document, we will refer to "database size" and "disk size":

  • Database size: Displays the actual size of the data within your Postgres database. This can be found on the Database Reports page.

  • Disk size: Shows the overall disk space usage, which includes both the database size and additional files required for Postgres to function like the Write Ahead Log (WAL) and other system log files. You can view this on the Database Settings page.

Database size

This SQL query will show the size of all databases in your Postgres cluster:


_10
select
_10
sum(pg_database_size(pg_database.datname)) / (1024 * 1024) as db_size_mb
_10
from pg_database;

This value is reported in the database report page.

Database size is consumed primarily by your data, indexes, and materialized views. You can reduce your database size by removing any of these and running a Vacuum operation.

Vacuum operations

Postgres 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 is executed. As a result, deleting data from your database may not immediately reduce the reported disk usage. You can use the Supabase CLI inspect db bloat command to view all dead tuples in your database. Alternatively, you can run the query found in the CLI's GitHub repo in the SQL Editor


_11
# Login to the CLI
_11
npx supabase login
_11
_11
# Initialize a local supabase directory
_11
npx supabase init
_11
_11
# Link a project
_11
npx supabase link
_11
_11
# Detect bloat
_11
npx supabase inspect db bloat --linked

If you find a table you would like to immediately clean, you can run the following in the SQL Editor:


_10
vacuum full <table name>;

Supabase projects have automatic vacuuming enabled, which ensures that these operations are performed regularly to keep the database healthy and performant. It is possible to fine-tune the autovacuum parameters, or manually initiate vacuum operations. Running a manual vacuum after deleting large amounts of data from your DB could help reduce the database size reported by Postgres.

Preoccupied space

New Supabase projects have a database size of ~40-60mb. This space includes pre-installed extensions, schemas, and default Postgres data. Additional database size is used when installing extensions, even if those extensions are inactive.

Disk size

Supabase uses network-attached storage to balance performance with scalability. The disk scaling behavior depends on your billing plan.

Projects on the Pro Plan and higher have auto-scaling disks.

Disk size expands automatically when the database reaches 90% of the allocated disk size. The disk is expanded to be 50% larger (for example, 8 GB -> 12 GB). Auto-scaling can only take place once every 6 hours. If within those 6 hours you reach 95% of the disk space, your project will enter read-only mode.

Disk size can also be manually expanded on the Database settings page. The maximum disk size for the Pro/Team Plan is 60 TB. If you need more than this, contact us to learn more about the Enterprise Plan.

Free Plan behavior

Free Plan projects enter read-only mode when you exceed the 500 MB limit. Once in read-only mode, you have these options:

Read-only mode

In some cases Supabase may put your database into read-only mode to prevent your database from exceeding the billing or disk limitations.

In read-only mode, clients will encounter errors such as cannot execute INSERT in a read-only transaction. Regular operation (read-write mode) is automatically re-enabled once usage is below 95% of the disk size,

Disabling read-only mode

You manually override read-only mode to reduce disk size. To do this, run the following in the SQL Editor:

First, change the transaction access mode:


_10
set session characteristics as transaction read write;

This allows you to delete data from within the session. After deleting data, consider running a vacuum to reclaim as much space as possible:


_10
vacuum;

Once you have reclaimed space, you can run the following to disable read-only mode:


_10
set default_transaction_read_only = 'off';

Reducing disk size

Disks don't automatically downsize during normal operation. Once you have reduced your database size, they will automatically "right-size" during a project upgrade. The final disk size after the upgrade is 1.2x the size of the database with a minimum of 8 GB. For example, if your database size is 100GB, and you have a 200GB disk, the size after a project upgrade will be 120 GB.

In the event that your project is already on the latest version of Postgres and cannot be upgraded, a new version of Postgres will be released approximately every week which you can then upgrade to once it becomes available.