How does Supabase meter uncached vs cached egress past 250 GB?
Supabase Pro ($25/month base) grants two independent 250 GB monthly bandwidth pools: Uncached Egress (origin database APIs, Realtime, Auth, and Storage cache misses) bills $0.09/GB past 250 GB, while Cached Egress (Storage Smart CDN cache hits) bills $0.03/GB past its own 250 GB allowance.
Egress (not compute or disk) is the number-one surprise line item on growing Supabase invoices. A project comfortably running on the baseline Micro compute instance ($10/month, fully zeroed out by Pro's $10 compute credit) with 8 GB of Postgres storage and 100,000 included MAUs can still rack up a $385/month bill if an unoptimized mobile feed or background loop pushes 4.25 TB of origin traffic (4,000 GB * $0.09 = $360 overage + $25 base). And on the Free plan, crossing the hard 5 GB total egress cap throttles or pauses project responses outright.
Understanding where your bytes land across December 2026 BaaS and object-storage providers immediately shows which workloads belong in Postgres, which belong on Smart CDN, and which must move to zero-egress storage:
| Provider & Traffic Path | Included Monthly Egress | Overage Rate per GB | Storage Cost per GB | Cost for 2 TB (2,048 GB) Monthly Transfer |
|---|---|---|---|---|
| Supabase Pro (Uncached Origin) | 250 GB (5 GB on Free) |
$0.09/GB |
8 GB DB ($0.125/GB) / 100 GB File ($0.021/GB) |
$186.82/mo ($25 base + $161.82 egress) |
| Supabase Pro (Smart CDN Cached) | 250 GB (separate pool) |
$0.03/GB |
100 GB File incl. ($0.021/GB extra) |
$78.94/mo ($25 base + $53.94 cached egress) |
| Firebase Blaze (Firestore / Storage) | 10 GB/mo (1 GB/day Hosting) |
$0.12/GB |
1 GB incl. ($0.15/GB extra) |
$244.56/mo (egress alone, excluding doc reads) |
| Neon Launch (Serverless Postgres) | 100 GB |
$0.09/GB |
10 GB DB incl. ($0.35/GB extra) |
$194.32/mo ($19 base + $175.32 egress) |
| Cloudflare R2 (Custom Domain CDN) | Unlimited ($0 egress) |
$0.00/GB |
10 GB incl. ($0.015/GB extra) |
$0.00/mo egress (~$1.35/mo for 100 GB stored) |
Run your exact database row sizes, monthly active users ($0.00325/MAU past 100k), and media bandwidth through our Supabase vs Firebase vs Neon cost calculator to see how moving heavy assets shifts your total cost curve. Unlike Firestore's per-document read billing, Supabase never charges per SQL row read, it only charges for the serialized wire bytes leaving the datacenter.
How do you find which Postgres queries burn egress using pg_stat_statements?
Open the Supabase Dashboard Observability -> Egress breakdown first to separate PostgREST (rest) from Storage (storage), then query pg_stat_statements alongside pg_stats in the SQL Editor to identify high-frequency authenticator queries returning wide JSONB, TEXT, or vector columns.
Before changing application code, verify which subsystem owns the spike. In your Supabase Dashboard under Organization -> Usage -> Egress, Supabase splits uncached traffic by service: Database / PostgREST, Storage, Realtime, Auth, and Edge Functions.
If Database / PostgREST accounts for more than 30% of your egress, run these two diagnostic queries in the Supabase SQL Editor. First, inspect your widest columns across public tables so you spot bloated JSONB, TEXT, or pgvector embeddings immediately:
-- 1. Find the widest average columns in your public schema (bytes per row)
SELECT
tablename,
attname AS column_name,
avg_width AS avg_bytes_per_row,
ROUND((avg_width * n_live_tup) / 1048576.0, 2) AS estimated_total_mb
FROM pg_stats s
JOIN pg_stat_user_tables t
ON s.schemaname = t.schemaname AND s.tablename = t.relname
WHERE s.schemaname = 'public'
AND avg_width > 256
ORDER BY avg_width DESC
LIMIT 20;
Second, query pg_stat_statements filtered to the authenticator role (PostgREST) or your direct ORM role (postgres) to rank queries by total rows shipped (rows) and execution count (calls):
-- 2. Rank PostgREST & ORM queries shipping the highest cumulative row volume
SELECT
rolname AS db_role,
calls,
rows AS total_rows_returned,
ROUND((rows::numeric / NULLIF(calls, 0)), 1) AS avg_rows_per_call,
ROUND(total_exec_time::numeric, 1) AS total_ms,
LEFT(query, 140) AS sql_fingerprint
FROM pg_stat_statements pss
JOIN pg_roles r ON r.oid = pss.userid
WHERE rolname IN ('authenticator', 'postgres')
AND rows > 1000
ORDER BY rows DESC
LIMIT 20;
Multiply total_rows_returned by the avg_bytes_per_row of that table's columns and the culprit jumps off the screen. A dashboard polling SELECT * FROM documents every 15 seconds where each row carries a 45 KB TipTap JSONB tree or a 6 KB vector(1536) column ships 4.5 MB per poll (100 rows * 45 KB), burning 25.9 GB per month per active admin tab!
Why does PostgREST select('*') silently multiply uncached egress?
Every byte returned by supabase.from('table').select('*') travels over uncached origin HTTPS ($0.09/GB), pulling heavy JSONB payloads, raw HTML/Markdown bodies, pgvector floats, and accidental data:image/png;base64 avatars into list views that only render three text fields.
In supabase-js, developers habitually write .select('*') during prototyping because TypeScript autocomplete infers the full row type effortlessly. In production, .select('*') creates three severe egress multipliers:
- Inline Base64 Avatars & Thumbnails: Storing a
120 KBdata:image/jpeg;base64,...string insideusers.avatar_urlinstead of a70-byteCDN URL inflates a50-member team roster response from6 KBto6 MB(1,000xbloat) on every page load. - Vector Embeddings & Rich-Text ASTs in List Endpoints: Tables that store
embedding vector(1536)alongsidetitleandsummaryserialize all1,536floating-point numbers as ASCII JSON arrays (~18 KBper row over JSON!) whenever.select('*')runs without column projection. - Mutation
.select()Echoes: Chaining.insert(payload).select('*')or.update(payload).select('*')when the UI only needs{ id }echoes the entire large row back across the wire unnecessarily.
Lock down PostgREST egress with explicit column projections, pagination bounds, and head: true count queries:
import { createClient } from "@supabase/supabase-js";
import type { Database } from "./database.types";
const supabase = createClient<Database>(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
);
// BAD: Pulls 45 KB content_json + 18 KB vector(1536) for 500 rows (~31.5 MB per call!)
// const { data } = await supabase.from("articles").select("*");
// GOOD: Explicit projection + strict range (~4.2 KB per call = 99.98% egress reduction)
export async function fetchArticleFeed(page = 0, pageSize = 20) {
const from = page * pageSize;
const to = from + pageSize - 1;
return supabase
.from("articles")
.select("id, slug, title, excerpt, cover_image_url, published_at")
.eq("status", "published")
.order("published_at", { ascending: false })
.range(from, to);
}
// GOOD: Count rows with ZERO row body egress (HTTP HEAD via PostgREST)
export async function fetchPublishedCount() {
const { count, error } = await supabase
.from("articles")
.select("id", { count: "exact", head: true })
.eq("status", "published");
if (error) throw error;
return count ?? 0;
}
For public, read-heavy PostgREST queries (such as landing page pricing tables, changelogs, or public directories), wrap the query inside a Next.js unstable_cache / Cache-Control: public, s-maxage=300, stale-while-revalidate=3600 API route or Cloudflare Worker cache so 50,000 visitors hit your edge cache instead of pulling uncached PostgREST JSON directly from browsers. If your serverless backend queries Postgres directly via Prisma or Drizzle, pair these narrow column select clauses with Supavisor port 6543 Transaction Mode so neither egress nor connection pools bottleneck under burst traffic.
How do storage cacheControl headers and Smart CDN slash bandwidth bills by 67%?
Switching static user uploads (avatars, thumbnails, public-media) to Public Buckets with content-addressed filenames and cacheControl: '31536000' shifts Storage traffic from $0.09/GB Uncached Egress to Smart CDN's separate 250 GB free pool and $0.03/GB Cached Egress tier.
By default, supabase.storage.from('bucket').upload(path, file) sets cacheControl: '3600' (1 hour). Worse, many teams store harmless public thumbnails inside Private Buckets and call createSignedUrl(path, 3600) on every SSR render. Because every signed URL appends a unique cryptographic ?token=... query parameter, CDN edge nodes treat each user's request as a brand-new cache key, resulting in a 0% CDN cache hit rate and billing 100% of image bytes at $0.09/GB Uncached Egress!
Fix Storage caching with three production rules:
- Use Public Buckets for non-confidential UI media: Keep sensitive KYC PDFs or invoices in Private Buckets with RLS, and move avatars, product photos, and cover images into a Public Bucket where clean URLs cache globally across all visitors via Supabase Smart CDN.
- Set
cacheControl: '31536000'(1 year) with immutable hashed keys: Include a content hash or timestamp in the filename (avatars/${userId}-${Date.now()}.webp) instead of overwritingavatars/${userId}.pngrepeatedly, and set a 1-year TTL on upload. (On Pro plans, Smart CDN also invalidates edge caches automatically within ~60 seconds when an object is updated or deleted via the Storage API, though fingerprinted URLs also bust browser memory caches immediately.) - Serve responsive thumbnails via Image Transformations: Never serve a raw
4.8 MBiPhone HEIC/PNG upload into a64x64avatar slot:
// Upload pre-compressed WebP or immutable asset with a 1-year Smart CDN TTL
export async function uploadPublicAvatar(userId: string, file: File) {
const ext = file.name.split(".").pop() ?? "webp";
const objectKey = `${userId}/${crypto.randomUUID()}.${ext}`;
const { data, error } = await supabase.storage
.from("public-avatars")
.upload(objectKey, file, {
cacheControl: "31536000", // 365 days at edge & browser
contentType: file.type,
upsert: false,
});
if (error) throw error;
// Request resized WebP via Smart CDN transformation endpoint (Pro plan)
const { data: thumb } = supabase.storage
.from("public-avatars")
.getPublicUrl(data.path, {
transform: { width: 128, height: 128, resize: "cover", quality: 80 },
});
return thumb.publicUrl;
}
Shrinking a 2.4 MB upload down to an 18 KB transformed WebP (133x smaller) and serving 96% of requests from Smart CDN ($0.03/GB past a fresh 250 GB quota) cuts effective image bandwidth spend by more than 99%.
When should you offload video and large binaries to Cloudflare R2?
Any workload streaming video (MP4, HLS), podcasts/audio, desktop installers, or downloadable archives larger than 5 MB should bypass Supabase Storage completely and serve bytes from Cloudflare R2 ($0.00/GB egress) while keeping metadata, Auth, and RLS authorization inside Supabase.
Even at Smart CDN's discounted $0.03/GB Cached Egress rate, video and heavy binary distribution destroys BaaS unit economics. Streaming a 40 MB onboarding video or course clip 250,000 times in a month consumes 10 TB (10,240 GB) of bandwidth, costing $299.70/month on Supabase Smart CDN ($899.10/month if uncached!), versus $0.00/month in egress on Cloudflare R2 (~$0.15/month storage).
You do not need to abandon Supabase to get zero-egress media. Use the battle-tested Supabase + R2 Hybrid Pattern:
- Authenticate & Authorize in Supabase: Verify the user's Supabase JWT inside a Next.js Route Handler or Edge Function and insert a row in your Postgres
media_assetstable protected by standard RLS policies. - Mint a Short-Lived R2 Presigned Upload URL: Use
@aws-sdk/client-s3+@aws-sdk/s3-request-presignerpointed athttps://<ACCOUNT_ID>.r2.cloudflarestorage.comso the browser uploads heavy bytes directly to R2 without touching your server or Supabase Storage:
import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
const r2 = new S3Client({
region: "auto",
endpoint: `https://${process.env.R2_ACCOUNT_ID}.r2.cloudflarestorage.com`,
credentials: {
accessKeyId: process.env.R2_ACCESS_KEY_ID!,
secretAccessKey: process.env.R2_SECRET_ACCESS_KEY!,
},
});
export async function createR2UploadUrl(objectKey: string, contentType: string) {
const command = new PutObjectCommand({
Bucket: process.env.R2_BUCKET_NAME!,
Key: objectKey,
ContentType: contentType,
CacheControl: "public, max-age=31536000, immutable",
});
// Valid for 5 minutes; client PUTs binary directly to Cloudflare R2
const uploadUrl = await getSignedUrl(r2, command, { expiresIn: 300 });
const publicCdnUrl = `https://media.yourdomain.com/${objectKey}`;
return { uploadUrl, publicCdnUrl };
}
- Serve via Custom Domain CDN: Attach a Cloudflare-proxied custom subdomain (
media.yourdomain.com) to your R2 bucket with a Cache Rule (Cache Everything, Edge TTL1 month) and store onlypublicCdnUrlinside your Supabase Postgres column. Pair this zero-egress media layer with Cloudflare edge database discipline and Supabase's Spend Cap toggle enabled in Billing Settings (which caps overages at your$25/monthPro base if you prefer hard quota enforcement over elastic$0.09/GBbilling) so a viral launch never triggers a four-figure bandwidth invoice.