From a4af144ae2bea74a5286012a3cae32881b38422e Mon Sep 17 00:00:00 2001 From: Div Arora Date: Mon, 19 Sep 2022 06:38:51 +0800 Subject: [PATCH 1/9] chore: adds docs for disk space usage. --- .../docs/guides/platform/disk-usage.mdx | 29 +++++++++++++++++++ .../docs/guides/platform/performance.mdx | 7 +++++ apps/reference/nav/_referenceSidebars.js | 1 + 3 files changed, 37 insertions(+) create mode 100644 apps/reference/docs/guides/platform/disk-usage.mdx 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', ], From b37014efdb8063a13675dbd309dd235cd84d1796 Mon Sep 17 00:00:00 2001 From: Div Arora Date: Tue, 20 Sep 2022 14:55:24 +0800 Subject: [PATCH 2/9] Update apps/reference/docs/guides/platform/disk-usage.mdx Co-authored-by: dng --- apps/reference/docs/guides/platform/disk-usage.mdx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/reference/docs/guides/platform/disk-usage.mdx b/apps/reference/docs/guides/platform/disk-usage.mdx index 7e975faceca..ebad2e91839 100644 --- a/apps/reference/docs/guides/platform/disk-usage.mdx +++ b/apps/reference/docs/guides/platform/disk-usage.mdx @@ -1,10 +1,9 @@ --- id: disk-usage -title: Disk Usage -description: Database Disk Space usage +title: Disk space usage +description: Learn how database disk space usage is reported. --- -# 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_. From 7f56574164a761b423a47ca998cfc6b39dfdc4ab Mon Sep 17 00:00:00 2001 From: Div Arora Date: Tue, 20 Sep 2022 14:56:04 +0800 Subject: [PATCH 3/9] Update apps/reference/docs/guides/platform/disk-usage.mdx Co-authored-by: dng --- apps/reference/docs/guides/platform/disk-usage.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/reference/docs/guides/platform/disk-usage.mdx b/apps/reference/docs/guides/platform/disk-usage.mdx index ebad2e91839..e43feb09589 100644 --- a/apps/reference/docs/guides/platform/disk-usage.mdx +++ b/apps/reference/docs/guides/platform/disk-usage.mdx @@ -13,7 +13,7 @@ For an instantaneous live view of the DB disk space being used by your project, 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). +This value is also reported in the [database settings page](https://app.supabase.com/project/_/settings/database). ## Vacuuming From 94c8c393f8e590a7ef9c1992b8ea376f017afdd5 Mon Sep 17 00:00:00 2001 From: Div Arora Date: Tue, 20 Sep 2022 14:58:30 +0800 Subject: [PATCH 4/9] Update apps/reference/docs/guides/platform/disk-usage.mdx Co-authored-by: dng --- apps/reference/docs/guides/platform/disk-usage.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/reference/docs/guides/platform/disk-usage.mdx b/apps/reference/docs/guides/platform/disk-usage.mdx index e43feb09589..9e707cf514c 100644 --- a/apps/reference/docs/guides/platform/disk-usage.mdx +++ b/apps/reference/docs/guides/platform/disk-usage.mdx @@ -5,7 +5,7 @@ description: Learn how database disk space usage is reported. --- -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_. +Database disk space usage refers to the _monthly average disk usage_, as reported by Postgres. This metric is reported in 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: From 406eb81a8b805366cab1ffaafcd7b12c65d8bba1 Mon Sep 17 00:00:00 2001 From: Div Arora Date: Tue, 20 Sep 2022 14:58:46 +0800 Subject: [PATCH 5/9] Update apps/reference/docs/guides/platform/disk-usage.mdx Co-authored-by: dng --- apps/reference/docs/guides/platform/disk-usage.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/reference/docs/guides/platform/disk-usage.mdx b/apps/reference/docs/guides/platform/disk-usage.mdx index 9e707cf514c..ca12179fe00 100644 --- a/apps/reference/docs/guides/platform/disk-usage.mdx +++ b/apps/reference/docs/guides/platform/disk-usage.mdx @@ -15,7 +15,7 @@ SELECT SUM(pg_database_size(pg_database.datname)) / (1024 * 1024) as db_size_mb This value is also reported in the [database settings page](https://app.supabase.com/project/_/settings/database). -## Vacuuming +## Vacuum operations :::note From d4fe236bad4ab55c94915870bed7334c64d8b8f3 Mon Sep 17 00:00:00 2001 From: Div Arora Date: Tue, 20 Sep 2022 14:58:57 +0800 Subject: [PATCH 6/9] Update apps/reference/docs/guides/platform/disk-usage.mdx Co-authored-by: dng --- apps/reference/docs/guides/platform/disk-usage.mdx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/apps/reference/docs/guides/platform/disk-usage.mdx b/apps/reference/docs/guides/platform/disk-usage.mdx index ca12179fe00..db0b7492135 100644 --- a/apps/reference/docs/guides/platform/disk-usage.mdx +++ b/apps/reference/docs/guides/platform/disk-usage.mdx @@ -17,12 +17,10 @@ This value is also reported in the [database settings page](https://app.supabase ## Vacuum operations +Postgres does not immediately reclaim the physical space used by dead tuples (i.e., deleted rows) in the DB. Instead, they are internally 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 DB may not immediately reduce the reported disk usage. + :::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. - +Vacuum operations can temporarily increase resource utilization, which can adversely impact the observed performance of your project until 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. From 7d2b6bed545f2a649bc39446a90ab671c9e02fa4 Mon Sep 17 00:00:00 2001 From: Div Arora Date: Tue, 20 Sep 2022 15:00:31 +0800 Subject: [PATCH 7/9] Update apps/reference/docs/guides/platform/disk-usage.mdx Co-authored-by: dng --- apps/reference/docs/guides/platform/disk-usage.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/reference/docs/guides/platform/disk-usage.mdx b/apps/reference/docs/guides/platform/disk-usage.mdx index db0b7492135..3fd2bc05cdf 100644 --- a/apps/reference/docs/guides/platform/disk-usage.mdx +++ b/apps/reference/docs/guides/platform/disk-usage.mdx @@ -23,4 +23,4 @@ Postgres does not immediately reclaim the physical space used by dead tuples (i. Vacuum operations can temporarily increase resource utilization, which can adversely impact the observed performance of your project until the maintenance is completed. ::: -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. +Supabase projects have automatic vacuuming, which ensures that these operations are performed regularly to keep the database healthy and performant. However, it can 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. For example, running a manual vacuum after deleting large amounts of data from your DB could help reduce the reported disk usage by Postgres. From 9263834100b8c147fd0c7d971a9c0e7e571ece3f Mon Sep 17 00:00:00 2001 From: Div Arora Date: Tue, 20 Sep 2022 15:01:16 +0800 Subject: [PATCH 8/9] Update apps/reference/docs/guides/platform/performance.mdx Co-authored-by: dng --- apps/reference/docs/guides/platform/performance.mdx | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/apps/reference/docs/guides/platform/performance.mdx b/apps/reference/docs/guides/platform/performance.mdx index 18c3f4c86ff..07dfa92dc61 100644 --- a/apps/reference/docs/guides/platform/performance.mdx +++ b/apps/reference/docs/guides/platform/performance.mdx @@ -38,14 +38,7 @@ 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. +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. `pg_stat_activity` only exposes information on direct connections to the database. Information on the number of connections to pgbouncer is available [via the metrics endpoint](../platform/metrics). 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. From e20e54d2fb0d10163490bbd65520daaf5e8c9982 Mon Sep 17 00:00:00 2001 From: Div Arora Date: Tue, 20 Sep 2022 15:01:29 +0800 Subject: [PATCH 9/9] Update apps/reference/nav/_referenceSidebars.js Co-authored-by: dng --- apps/reference/nav/_referenceSidebars.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/reference/nav/_referenceSidebars.js b/apps/reference/nav/_referenceSidebars.js index 48f41ad26ed..2e47286a98a 100644 --- a/apps/reference/nav/_referenceSidebars.js +++ b/apps/reference/nav/_referenceSidebars.js @@ -189,12 +189,12 @@ const sidebars = { label: 'Platform', collapsed: true, items: [ + 'guides/platform/disk-usage', 'guides/platform/logs', 'guides/platform/metrics', - 'going-into-prod', - 'guides/platform/disk-usage', 'guides/platform/performance', 'guides/platform/permissions', + 'going-into-prod', ], }, {