0

Observability: logs, advisors & pg_stat_statements

Opsused in ~65% of apps

DevLog's feed goes from instant to 900ms with no code change and no deploy. There was no error, no red dashboard, nothing to grep in your own logs — just "it's slow now." The senior-engineer skill this concept teaches isn't running EXPLAIN; it's knowing what to check FIRST, in what order, so you find the one expensive query out of thousands instead of guessing.

Core idea. Supabase gives you four separate observability tools, each answering a different question: Logs tell you WHAT happened; Advisors tell you what's WRONG in your schema right now, without you asking; pg_stat_statements tells you WHICH query is actually costing the most, in aggregate, across every call; and EXPLAIN tells you WHY one specific query is slow. The professional triage order is logs and advisors first, pg_stat_statements second, EXPLAIN last — reaching for EXPLAIN before the first two is how you spend an hour tuning a query that was never the problem.
Playground, this isn't a screenshot
order by
Feed: posts by user_id (no index)top by this metric
select * from posts where user_id = $1
calls: 200,000total: 360,000ms (65.7%)mean: 1.80ms
Feed: join to profiles (indexed)
select p.*, pr.username from posts p
join profiles pr on pr.id = p.user_id
calls: 500,000total: 100,000ms (18.2%)mean: 0.20ms
Admin: monthly rollup
select date_trunc('month', created_at), count(*)
from posts group by 1
calls: 40total: 88,000ms (16.1%)mean: 2200.00ms

Sorted by total_exec_time, the unindexed feed query wins — 200,000 cheap calls beat 40 expensive ones in aggregate. Sorted by mean_exec_time, the monthly rollup wins — it is genuinely the slowest single call, but it runs so rarely it barely dents your compute bill. Fix the first one for load; fix the second one for the one dashboard load that times out.

↑ play a little first, then dig in