Skip to content

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

feat: improved disk size insights (#30827)

Kevin Grüneberg98797fc6b8ce
diff --git a/apps/docs/content/guides/platform/compute-and-disk.mdx b/apps/docs/content/guides/platform/compute-and-disk.mdx
index 0b4e26f21c0..74aeec43fef 100644
--- a/apps/docs/content/guides/platform/compute-and-disk.mdx
+++ b/apps/docs/content/guides/platform/compute-and-disk.mdx
@@ -108,13 +108,14 @@ Be aware that increasing IOPS or throughput incurs additional charges.
When selecting your disk, it's essential to focus on the performance needs of your workload. Here's a comparison of our available disk types:
-| | General Purpose SSD (gp3) | High Performance SSD (io2) |
-| ----------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
-| **Use Case** | General workloads, development environments, small to medium databases | High-performance needs, large-scale databases, mission-critical applications |
-| **Max Disk Size** | 16 TB | 60 TB |
-| **Max IOPS** | 16,000 IOPS (at 32 GB disk size) | 80,000 IOPS (at 80 GB disk size) |
-| **Throughput** | 125 MiB/s (default) to 1,000 MiB/s (maximum) | Automatically scales with IOPS |
-| **Best For** | Great value for most use cases | Low latency and very high IOPS requirements |
+| | General Purpose SSD (gp3) | High Performance SSD (io2) |
+| ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
+| **Use Case** | General workloads, development environments, small to medium databases | High-performance needs, large-scale databases, mission-critical applications |
+| **Max Disk Size** | 16 TB | 60 TB |
+| **Max IOPS** | 16,000 IOPS (at 32 GB disk size) | 80,000 IOPS (at 80 GB disk size) |
+| **Throughput** | 125 MiB/s (default) to 1,000 MiB/s (maximum) | Automatically scales with IOPS |
+| **Best For** | Great value for most use cases | Low latency and very high IOPS requirements |
+| **Pricing** | Disk: 8 GB included, then $0.125 per GB<br/>IOPS: 3,000 included, then $0.024 per IOPS<br/>Throughput: 125 Mbps included, then $0.95 per Mbps | Disk: $0.195 per GB<br/>IOPS: $0.119 per IOPS<br/>Throughput: Scales with IOPS at no additional cost |
For general, day-to-day operations, gp3 should be more than enough. If you need high throughput and IOPS for critical systems, io2 will provide the performance required.
diff --git a/apps/docs/content/guides/platform/database-size.mdx b/apps/docs/content/guides/platform/database-size.mdx
index bb9174b5f9f..a4774aa07a0 100644
--- a/apps/docs/content/guides/platform/database-size.mdx
+++ b/apps/docs/content/guides/platform/database-size.mdx
@@ -139,8 +139,22 @@ Once you have reclaimed space, you can run the following to disable [read-only](
set default_transaction_read_only = 'off';
```
+### Disk Size Distribution
+
+You can check the distribution of your disk size on your [project's compute and disk page](/dashboard/_/settings/compute-and-disk).
+
+![Disk Size Distribution](/docs/img/guides/platform/database-size/disk-size-distribution.png)
+
+Your disk size usage falls in three categories:
+
+- **Database** - Disk usage by the database. This includes the actual data, indexes, materialized views, ...
+- **WAL** - Disk usage by the write-ahead log. The usage depends on your WAL settings and the amount of data being written to the database.
+- **System** - Disk usage reserved by the system to ensure the database can operate smoothly. Users cannot modify this and it should only take very little space.
+
### Reducing disk size
Disks don't automatically downsize during normal operation. Once you have [reduced your database size](/docs/guides/platform/database-size#database-size), they _will_ automatically "right-size" during a [project upgrade](/docs/guides/platform/upgrading). 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 case you have a large WAL directory, you may [modify WAL settings](/docs/guides/database/custom-postgres-config) such as `max_wal_size`. Use at your own risk as changing these settings can have side effects. To query your current WAL size, use `SELECT SUM(size) FROM pg_ls_waldir()`.
+
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.
diff --git a/apps/docs/public/img/guides/platform/database-size/disk-size-distribution.png b/apps/docs/public/img/guides/platform/database-size/disk-size-distribution.png
new file mode 100644
index 00000000000..32d0648b3d1
Binary files /dev/null and b/apps/docs/public/img/guides/platform/database-size/disk-size-distribution.png differ
diff --git a/apps/studio/components/interfaces/DiskManagement/fields/ComputeSizeField.tsx b/apps/studio/components/interfaces/DiskManagement/fields/ComputeSizeField.tsx
index 24c0638a1eb..fdf94851a4c 100644
--- a/apps/studio/components/interfaces/DiskManagement/fields/ComputeSizeField.tsx
+++ b/apps/studio/components/interfaces/DiskManagement/fields/ComputeSizeField.tsx
@@ -23,6 +23,7 @@ import { BillingChangeBadge } from '../ui/BillingChangeBadge'
import FormMessage from '../ui/FormMessage'
import { NoticeBar } from '../ui/NoticeBar'
import { InstanceSpecs } from 'lib/constants'
+import { DocsButton } from 'components/ui/DocsButton'
/**
* to do: this could be a type from api-types
@@ -137,6 +138,14 @@ export function ComputeSizeField({ form, disabled }: ComputeSizeFieldProps) {
<p className="text-foreground-lighter">
Hardware resources allocated to your Postgres database
</p>
+
+ <div className="mt-3">
+ <DocsButton
+ abbrev={false}
+ href="https://supabase.com/docs/guides/platform/compute-and-disk"
+ />
+ </div>
+
<NoticeBar
showIcon={false}
type="default"
diff --git a/apps/studio/components/interfaces/DiskManagement/fields/DiskSizeField.tsx b/apps/studio/components/interfaces/DiskManagement/fields/DiskSizeField.tsx
index d8602ff4491..8f853acaf5c 100644
--- a/apps/studio/components/interfaces/DiskManagement/fields/DiskSizeField.tsx
+++ b/apps/studio/components/interfaces/DiskManagement/fields/DiskSizeField.tsx
@@ -19,6 +19,9 @@ import { DiskTypeRecommendationSection } from '../ui/DiskTypeRecommendationSecti
import FormMessage from '../ui/FormMessage'
import { InputPostTab } from '../ui/InputPostTab'
import { InputResetButton } from '../ui/InputResetButton'
+import { Admonition } from 'ui-patterns'
+import Markdown from 'markdown-to-jsx'
+import { DocsButton } from 'components/ui/DocsButton'
type DiskSizeFieldProps = {
form: UseFormReturn<DiskStorageSchemaType>
@@ -148,6 +151,13 @@ export function DiskSizeField({
{includedDiskGB > 0 &&
subscription?.plan.id &&
`Your plan includes ${includedDiskGB} GB of disk size for ${watchedStorageType}.`}
+
+ <div className="mt-3">
+ <DocsButton
+ abbrev={false}
+ href="https://supabase.com/docs/guides/platform/database-size"
+ />
+ </div>
</span>
<DiskTypeRecommendationSection
form={form}
diff --git a/apps/studio/components/interfaces/DiskManagement/ui/DiskSpaceBar.tsx b/apps/studio/components/interfaces/DiskManagement/ui/DiskSpaceBar.tsx
index e75ac95346e..eaf93bf903d 100644
--- a/apps/studio/components/interfaces/DiskManagement/ui/DiskSpaceBar.tsx
+++ b/apps/studio/components/interfaces/DiskManagement/ui/DiskSpaceBar.tsx
@@ -5,10 +5,7 @@ import { useTheme } from 'next-themes'
import { UseFormReturn } from 'react-hook-form'
import { useParams } from 'common'
-import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
-import { useRemainingDurationForDiskAttributeUpdate } from 'data/config/disk-attributes-query'
import { useDiskUtilizationQuery } from 'data/config/disk-utilization-query'
-import { useDatabaseSizeQuery } from 'data/database/database-size-query'
import { GB } from 'lib/constants'
import { formatBytes } from 'lib/helpers'
import {
@@ -20,6 +17,9 @@ import {
} from 'ui'
import { DiskStorageSchemaType } from '../DiskManagement.schema'
import { AUTOSCALING_THRESHOLD } from './DiskManagement.constants'
+import { useDiskBreakdownQuery } from 'data/config/disk-breakdown-query'
+import { useSelectedProject } from 'hooks/misc/useSelectedProject'
+import { useMemo } from 'react'
interface DiskSpaceBarProps {
form: UseFormReturn<DiskStorageSchemaType>
@@ -30,6 +30,7 @@ export default function DiskSpaceBar({ form }: DiskSpaceBarProps) {
const { resolvedTheme } = useTheme()
const { formState, watch } = form
const isDarkMode = resolvedTheme?.includes('dark')
+ const project = useSelectedProject()
const {
data: diskUtil,
@@ -38,30 +39,54 @@ export default function DiskSpaceBar({ form }: DiskSpaceBarProps) {
projectRef: ref,
})
- const usedSize = Math.round(((diskUtil?.metrics.fs_used_bytes ?? 0) / GB) * 100) / 100
- const totalSize = formState.defaultValues?.totalSize || 0
- const show = formState.dirtyFields.totalSize !== undefined && usedSize
+ const { data: diskBreakdown } = useDiskBreakdownQuery({
+ projectRef: ref,
+ connectionString: project?.connectionString,
+ })
+
+ const diskBreakdownBytes = useMemo(() => {
+ return {
+ availableBytes: diskUtil?.metrics.fs_avail_bytes ?? 0,
+ totalUsedBytes: diskUtil?.metrics.fs_used_bytes ?? 0,
+ totalDiskSizeBytes: diskUtil?.metrics.fs_size_bytes,
+ dbSizeBytes: Math.max(0, diskBreakdown?.db_size_bytes ?? 0),
+ walSizeBytes: Math.max(0, diskBreakdown?.wal_size_bytes ?? 0),
+ systemBytes: Math.max(
+ 0,
+ (diskUtil?.metrics.fs_used_bytes ?? 0) -
+ (diskBreakdown?.db_size_bytes ?? 0) -
+ (diskBreakdown?.wal_size_bytes ?? 0)
+ ),
+ }
+ }, [diskUtil, diskBreakdown])
+
+ const showNewSize = formState.dirtyFields.totalSize !== undefined && diskBreakdown
const newTotalSize = watch('totalSize')
- const usedPercentage = (usedSize / totalSize) * 100
- const resizePercentage = AUTOSCALING_THRESHOLD * 100
+ const totalSize = formState.defaultValues?.totalSize || 0
+ const usedSizeTotal = Math.round(((diskBreakdownBytes?.totalUsedBytes ?? 0) / GB) * 100) / 100
+ const usedTotalPercentage = Math.min((usedSizeTotal / totalSize) * 100, 100)
- const newUsedPercentage = (usedSize / newTotalSize) * 100
- const newResizePercentage = AUTOSCALING_THRESHOLD * 100
+ const usedSizeDatabase = Math.round(((diskBreakdownBytes?.dbSizeBytes ?? 0) / GB) * 100) / 100
+ const usedPercentageDatabase = Math.min((usedSizeDatabase / totalSize) * 100, 100)
+ const newUsedPercentageDatabase = Math.min((usedSizeDatabase / newTotalSize) * 100, 100)
- const { project } = useProjectContext()
- const { data } = useDatabaseSizeQuery({
- projectRef: project?.ref,
- connectionString: project?.connectionString,
- })
- const { remainingDuration } = useRemainingDurationForDiskAttributeUpdate({ projectRef: ref })
+ const usedSizeWAL = Math.round(((diskBreakdownBytes?.walSizeBytes ?? 0) / GB) * 100) / 100
+ const usedPercentageWAL = Math.min((usedSizeWAL / totalSize) * 100, 100)
+ const newUsedPercentageWAL = Math.min((usedSizeWAL / newTotalSize) * 100, 100)
+
+ const usedSizeSystem = Math.round(((diskBreakdownBytes?.systemBytes ?? 0) / GB) * 100) / 100
+ const usedPercentageSystem = Math.min((usedSizeSystem / totalSize) * 100, 100)
+ const newUsedPercentageSystem = Math.min((usedSizeSystem / newTotalSize) * 100, 100)
+
+ const resizePercentage = AUTOSCALING_THRESHOLD * 100
+ const newResizePercentage = AUTOSCALING_THRESHOLD * 100
- const databaseSizeBytes = data ?? 0
return (
<div className="flex flex-col gap-2">
<div className="flex items-center h-6 gap-3">
<span className="text-foreground-light text-sm font-mono flex items-center gap-2">
- {usedSize.toFixed(2)}
+ {usedSizeTotal.toFixed(2)}
<span>GB used of </span>
<span className="text-foreground font-semibold -mt-[2px]">
<MotionNumber value={newTotalSize} style={{ lineHeight: 0.8 }} className="font-mono" />
@@ -73,85 +98,67 @@ export default function DiskSpaceBar({ form }: DiskSpaceBarProps) {
<div
className={cn(
'h-[35px] relative border rounded-sm w-full transition',
- show ? 'bg-selection border border-brand-button' : 'bg-surface-300'
+ showNewSize ? 'bg-selection border border-brand-button' : 'bg-surface-300'
)}
>
<AnimatePresence>
- {!show ? (
- <motion.div
- key="currentBar"
- initial={{ rotateY: 90, zIndex: 2 }}
- animate={{ rotateY: 0, zIndex: 1 }}
- exit={{ rotateY: -90, zIndex: 2 }}
- transition={{ duration: 0.3 }}
- style={{ transformOrigin: 'left center', backfaceVisibility: 'hidden' }}
- className="absolute inset-0 rounded-sm overflow-hidden"
- >
- <div className="h-full flex">
+ <motion.div
+ key="currentBar"
+ initial={{ rotateY: 90, zIndex: 2 }}
+ animate={{ rotateY: 0, zIndex: 1 }}
+ exit={{ rotateY: -90, zIndex: 2 }}
+ transition={{ duration: 0.3 }}
+ style={{ transformOrigin: 'left center', backfaceVisibility: 'hidden' }}
+ className="absolute inset-0 rounded-sm overflow-hidden"
+ >
+ <div className="h-full flex">
+ <div
+ className="relative overflow-hidden transition-all duration-500 ease-in-out bg-foreground"
+ style={{
+ width: `${showNewSize ? newUsedPercentageDatabase : usedPercentageDatabase}%`,
+ }}
+ >
<div
- className={cn(
- usedPercentage >= 90 && remainingDuration > 0
- ? 'bg-destructive'
- : 'bg-foreground',
- 'relative overflow-hidden transition-all duration-500 ease-in-out'
- )}
- style={{ width: `${usedPercentage >= 100 ? 100 : usedPercentage}%` }}
- >
- <div
- className="absolute inset-0"
- style={{
- backgroundImage: `repeating-linear-gradient(
+ className="absolute inset-0"
+ style={{
+ backgroundImage: `repeating-linear-gradient(
-45deg,
${isDarkMode ? 'rgba(0,0,0,0.1)' : 'rgba(255,255,255,0.1)'},
${isDarkMode ? 'rgba(0,0,0,0.1) 1px' : 'rgba(255,255,255,0.1) 1px'},
transparent 1px,
transparent 4px
)`,
- }}
- />
- </div>
- <div
- className="bg-transparent border-r transition-all duration-500 ease-in-out"
- style={{
- width: `${resizePercentage - usedPercentage <= 0 ? 0 : resizePercentage - usedPercentage}%`,
}}
/>
</div>
- </motion.div>
- ) : (
- <motion.div
- key="newBar"
- initial={{ rotateY: -90, zIndex: 2 }}
- animate={{ rotateY: 0, zIndex: 1 }}
- exit={{ rotateY: 90, zIndex: 2 }}
- transition={{ duration: 0.3 }}
- style={{ transformOrigin: 'left center', backfaceVisibility: 'hidden' }}
- className="absolute inset-0 rounded-sm overflow-hidden"
- >
- <div className="h-full flex">
+
+ <div
+ className="relative overflow-hidden transition-all duration-500 ease-in-out bg-_secondary"
+ style={{
+ width: `${showNewSize ? newUsedPercentageWAL : usedPercentageWAL}%`,
+ }}
+ />
+
+ <div
+ className="relative overflow-hidden transition-all duration-500 ease-in-out bg-destructive-500"
+ style={{
+ width: `${showNewSize ? newUsedPercentageSystem : usedPercentageSystem}%`,
+ }}
+ />
+
+ {!showNewSize && (
<div
- className="bg-foreground relative overflow-hidden transition-all duration-500 ease-in-out"
- style={{ width: `${newUsedPercentage >= 100 ? 100 : newUsedPercentage}%` }}
- >
- <div
- className="absolute inset-0"
- style={{
- backgroundImage: `repeating-linear-gradient(
- -45deg,
- ${isDarkMode ? 'rgba(0,0,0,0.1)' : 'rgba(255,255,255,0.1)'},
- ${isDarkMode ? 'rgba(0,0,0,0.1) 1px' : 'rgba(255,255,255,0.1) 1px'},
- transparent 1px,
- transparent 4px
- )`,
- }}
- />
- </div>
- </div>
- </motion.div>
- )}
+ className="bg-transparent-800 border-r transition-all duration-500 ease-in-out"
+ style={{
+ width: `${resizePercentage - usedTotalPercentage <= 0 ? 0 : resizePercentage - usedTotalPercentage}%`,
+ }}
+ />
+ )}
+ </div>
+ </motion.div>
</AnimatePresence>
<AnimatePresence>
- {show && (
+ {showNewSize && (
<motion.span
initial={{ opacity: 0, x: 4 }}
animate={{ opacity: 1, x: 0 }}
@@ -165,7 +172,7 @@ export default function DiskSpaceBar({ form }: DiskSpaceBarProps) {
</AnimatePresence>
</div>
<AnimatePresence initial={true}>
- {!show && (
+ {!showNewSize && (
<motion.div
key="currentSize"
initial={{ opacity: 0, y: -10 }}
@@ -176,7 +183,7 @@ export default function DiskSpaceBar({ form }: DiskSpaceBarProps) {
>
<div
className="absolute top-0 -left-0 h-full flex items-center transition-all duration-500 ease-in-out"
- style={{ left: `${show ? newResizePercentage : resizePercentage}%` }}
+ style={{ left: `${showNewSize ? newResizePercentage : resizePercentage}%` }}
>
<Tooltip_Shadcn_>
<TooltipTrigger_Shadcn_ asChild>
@@ -202,24 +209,75 @@ export default function DiskSpaceBar({ form }: DiskSpaceBarProps) {
)}
</AnimatePresence>
</div>
- {!show && (
- <div className="flex items-center space-x-4 text-xs text-foreground-lighter">
- <div className="flex items-center">
- <div className="w-2 h-2 rounded-full bg-foreground mr-2" />
- <span>Used Space</span>
- </div>
- <div className="flex items-center">
- <div className="w-2 h-2 rounded-full bg-border border border-strong mr-2" />
- <span>Available space</span>
- </div>
+ {!showNewSize && (
+ <div className="flex items-center space-x-3 text-xs text-foreground-lighter">
+ <LegendItem
+ name="Database"
+ size={diskBreakdownBytes.dbSizeBytes}
+ color="bg-foreground"
+ description="Total space on disk used by your database (tables, indexes, data, ...)."
+ />
+ <LegendItem
+ name="WAL"
+ size={diskBreakdownBytes.walSizeBytes}
+ color="bg-_secondary"
+ description="Total space on disk used by the write-ahead log."
+ />
+
+ <LegendItem
+ name="System"
+ size={diskBreakdownBytes.systemBytes}
+ color="bg-destructive-500"
+ description="Reserved space for the system to ensure your database runs smoothly. You cannot modify this."
+ />
+
+ <LegendItem
+ name="Available space"
+ size={diskBreakdownBytes.availableBytes}
+ color="bg-border"
+ description="Total available space on the disk left."
+ />
</div>
)}
<p className="text-xs text-foreground-lighter my-4">
<span className="font-semibold">Note:</span> Disk Size refers to the total space your
project occupies on disk, including the database itself (currently{' '}
- <span>{formatBytes(databaseSizeBytes, 2, 'GB')}</span>), additional files like the
- write-ahead log (WAL), and other internal resources.
+ <span>{formatBytes(diskBreakdownBytes?.dbSizeBytes, 2, 'GB')}</span>), additional files like
+ the write-ahead log (currently{' '}
+ <span>{formatBytes(diskBreakdownBytes?.walSizeBytes, 2, 'GB')}</span>), and other system
+ resources (currently <span>{formatBytes(diskBreakdownBytes?.systemBytes, 2, 'GB')}</span>).
+ Data can take 5 minutes to refresh.
</p>
</div>
)
}
+
+const LegendItem = ({
+ name,
+ description,
+ color,
+ size,
+}: {
+ name: string
+ description: string
+ color: string
+ size: number
+}) => (
+ <Tooltip_Shadcn_>
+ <TooltipTrigger_Shadcn_ asChild>
+ <div className="flex items-center hover:cursor-help z-10">
+ <div className={cn('w-2 h-2 rounded-full mr-2', color)} />
+ <span>{name}</span>
+ </div>
+ </TooltipTrigger_Shadcn_>
+ <TooltipContent_Shadcn_ side="bottom" className="flex flex-col gap-y-1 max-w-xs">
+ <div className="flex items-center">
+ <div className={cn('w-2 h-2 rounded-full mr-2', color)} />
+ <span>
+ {name} - {formatBytes(size, 2, 'GB')}
+ </span>
+ </div>
+ <p>{description}</p>
+ </TooltipContent_Shadcn_>
+ </Tooltip_Shadcn_>
+)
diff --git a/apps/studio/components/interfaces/Organization/Usage/UsageSection/DiskUsage.tsx b/apps/studio/components/interfaces/Organization/Usage/UsageSection/DiskUsage.tsx
index 5383630a199..df7486172fe 100644
--- a/apps/studio/components/interfaces/Organization/Usage/UsageSection/DiskUsage.tsx
+++ b/apps/studio/components/interfaces/Organization/Usage/UsageSection/DiskUsage.tsx
@@ -178,7 +178,7 @@ const DiskUsage = ({
{project.name}
</span>
<Button asChild type="default" size={'tiny'}>
- <Link href={`/project/${project.ref}/settings/database#disk-management`}>
+ <Link href={`/project/${project.ref}/settings/compute-and-disk`}>
Manage Disk
</Link>
</Button>
diff --git a/apps/studio/data/config/disk-breakdown-query.ts b/apps/studio/data/config/disk-breakdown-query.ts
new file mode 100644
index 00000000000..5218d40d51f
--- /dev/null
+++ b/apps/studio/data/config/disk-breakdown-query.ts
@@ -0,0 +1,59 @@
+import { useQuery, UseQueryOptions } from '@tanstack/react-query'
+
+import type { ResponseError } from 'types'
+import { configKeys } from './keys'
+import { executeSql } from 'data/sql/execute-sql-query'
+
+export type DiskBreakdownVariables = {
+ projectRef?: string
+ connectionString?: string
+}
+
+type DiskBreakdownResult = {
+ db_size_bytes: number
+ wal_size_bytes: number
+}
+
+export async function getDiskBreakdown(
+ { projectRef, connectionString }: DiskBreakdownVariables,
+ signal?: AbortSignal
+) {
+ if (!projectRef) throw new Error('Project ref is required')
+ if (!connectionString) throw new Error('Connection string is required')
+
+ const { result } = await executeSql(
+ {
+ projectRef,
+ connectionString,
+ sql: `
+ SELECT
+ (
+ SELECT
+ SUM(pg_database_size(pg_database.datname)) AS db_size_bytes
+ FROM
+ pg_database
+ ),
+ (
+ SELECT SUM(size)
+ FROM
+ pg_ls_waldir()
+ ) AS wal_size_bytes`,
+ },
+ signal
+ )
+
+ return result[0] as DiskBreakdownResult
+}
+
+export type DiskBreakdownData = Awaited<ReturnType<typeof getDiskBreakdown>>
+export type DiskBreakdownError = ResponseError
+
+export const useDiskBreakdownQuery = <TData = DiskBreakdownData>(
+ { projectRef, connectionString }: DiskBreakdownVariables,
+ { enabled = true, ...options }: UseQueryOptions<DiskBreakdownData, DiskBreakdownError, TData> = {}
+) =>
+ useQuery<DiskBreakdownData, DiskBreakdownError, TData>(
+ configKeys.diskBreakdown(projectRef),
+ ({ signal }) => getDiskBreakdown({ projectRef, connectionString }, signal),
+ { enabled: enabled && typeof projectRef !== 'undefined', ...options }
+ )
diff --git a/apps/studio/data/config/keys.ts b/apps/studio/data/config/keys.ts
index a2aab7748f1..e154ed65481 100644
--- a/apps/studio/data/config/keys.ts
+++ b/apps/studio/data/config/keys.ts
@@ -14,6 +14,8 @@ export const configKeys = {
['projects', projectRef, 'upgrade-status'] as const,
diskAttributes: (projectRef: string | undefined) =>
['projects', projectRef, 'disk-attributes'] as const,
+ diskBreakdown: (projectRef: string | undefined) =>
+ ['projects', projectRef, 'disk-breakdown'] as const,
diskUtilization: (projectRef: string | undefined) =>
['projects', projectRef, 'disk-utilization'] as const,
projectCreationPostgresVersions: (
diff --git a/apps/studio/pages/project/[ref]/reports/database.tsx b/apps/studio/pages/project/[ref]/reports/database.tsx
index 6584073bb36..0bc73dd4795 100644
--- a/apps/studio/pages/project/[ref]/reports/database.tsx
+++ b/apps/studio/pages/project/[ref]/reports/database.tsx
@@ -22,7 +22,6 @@ import { useProjectDiskResizeMutation } from 'data/config/project-disk-resize-mu
import { useDatabaseSizeQuery } from 'data/database/database-size-query'
import { useDatabaseReport } from 'data/reports/database-report-query'
import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'
-import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
import { useFlag } from 'hooks/ui/useFlag'
import { TIME_PERIODS_INFRA } from 'lib/constants/metrics'
import { formatBytes } from 'lib/helpers'
@@ -46,7 +45,6 @@ const DatabaseUsage = () => {
const { project } = useProjectContext()
const diskManagementV2 = useFlag('diskManagementV2')
- const org = useSelectedOrganization()
const state = useDatabaseSelectorStateSnapshot()
const [dateRange, setDateRange] = useState<any>(undefined)
@@ -220,23 +218,20 @@ const DatabaseUsage = () => {
renderer={(props) => {
return (
<div>
- <p className="text-sm -mt-4 text-foreground-lighter">
- The data refreshes every 24 hours.
- </p>
<div className="col-span-4 inline-grid grid-cols-12 gap-12 w-full mt-5">
<div className="grid gap-2 col-span-2">
<h5 className="text-sm">Space used</h5>
<span className="text-lg">{formatBytes(databaseSizeBytes, 2, 'GB')}</span>
</div>
<div className="grid gap-2 col-span-2">
- <h5 className="text-sm">Total size</h5>
+ <h5 className="text-sm">Provisioned disk size</h5>
<span className="text-lg">{currentDiskSize} GB</span>
</div>
<div className="col-span-8 text-right">
{showNewDiskManagementUI ? (
<Button asChild type="default">
- <Link href={`/project/${ref}/settings/database#disk-management`}>
+ <Link href={`/project/${ref}/settings/compute-and-disk`}>
Increase disk size
</Link>
</Button>
@@ -309,11 +304,11 @@ const DatabaseUsage = () => {
<Button asChild type="default" icon={<ExternalLink />}>
<Link
- href="https://supabase.com/docs/guides/platform/database-size#database-space-management"
+ href="https://supabase.com/docs/guides/platform/database-size#disk-space-usage"
target="_blank"
rel="noreferrer"
>
- Read about database space
+ Read about database size
</Link>
</Button>
</div>