Skip to content

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

Chore/disk size helper (#29952)

Terry Suttonb2cd52aac858
diff --git a/apps/studio/components/interfaces/DiskManagement/DiskSpaceBar.tsx b/apps/studio/components/interfaces/DiskManagement/DiskSpaceBar.tsx
index 1f3ff172e64..4c588d05af4 100644
--- a/apps/studio/components/interfaces/DiskManagement/DiskSpaceBar.tsx
+++ b/apps/studio/components/interfaces/DiskManagement/DiskSpaceBar.tsx
@@ -9,6 +9,10 @@ import {
TooltipTrigger_Shadcn_,
} from 'ui'
import { AUTOSCALING_THRESHOLD } from './DiskManagement.constants'
+import { Info } from 'lucide-react'
+import { formatBytes } from 'lib/helpers'
+import { useDatabaseSizeQuery } from 'data/database/database-size-query'
+import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
interface DiskSpaceBarProps {
showNewBar: boolean
@@ -29,6 +33,13 @@ export default function DiskSpaceBar({
const newUsedPercentage = (usedSize / newTotalSize) * 100
const newResizePercentage = AUTOSCALING_THRESHOLD * 100
+ const { project } = useProjectContext()
+ const { data } = useDatabaseSizeQuery({
+ projectRef: project?.ref,
+ connectionString: project?.connectionString,
+ })
+
+ const databaseSizeBytes = data?.result[0].db_size ?? 0
return (
<div className="flex flex-col gap-2">
<div className="flex items-center h-6 gap-3">
@@ -154,8 +165,8 @@ export default function DiskSpaceBar({
>
<Tooltip_Shadcn_>
<TooltipTrigger_Shadcn_ asChild>
- <div className="absolute right-full bottom-0 border mr-2 px-2 py-1 bg-surface-400 rounded text-xs text-foreground-light whitespace-nowrap">
- Autoscaling
+ <div className="absolute right-full bottom-0 border mr-2 px-2 py-1 bg-surface-400 rounded text-xs text-foreground-light whitespace-nowrap flex items-center gap-x-1">
+ Autoscaling <Info size={12} />
</div>
</TooltipTrigger_Shadcn_>
<TooltipContent_Shadcn_ side="bottom" className="w-[310px] flex flex-col gap-y-1">
@@ -186,6 +197,12 @@ export default function DiskSpaceBar({
<span>Available space</span>
</div>
</div>
+ <p className="text-xs text-foreground-lighter mt-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.
+ </p>
</div>
)
}