Why Your App Gets Slower With Every New User

Your app gets slower with every new user because every user adds rows, and most AI-written queries read far more rows than they need. A query that touches 100 rows returns in milliseconds. The same query over 100,000 rows takes seconds, and a few of those running at once stall the whole app.
The fix is almost always boring: an index, a LIMIT, and fewer queries per page. Each cause below links to a deep post with a runnable fail-then-pass test; this post is the map.
Why nobody notices in week one
In week one your tables hold dozens of rows. At that size Postgres often ignores indexes entirely, because reading the whole table is cheaper than detouring through one. So a missing index costs you nothing, and the AI that scaffolded your app often added none beyond the primary key. Everything feels instant.
Then real users arrive. Each one adds rows to orders, messages, events. The same queries keep running, but each run reads more than last week. The app does not slow down gradually. It falls off a cliff the day one table crosses a size your queries cannot scan politely.
The four ways it shows up
1. The full-table scan. Finding one user’s orders without an index means reading every row in the table and throwing away the ones that do not match. Postgres does not index foreign keys automatically, so that innocent WHERE user_id = ... the AI wrote scans every order in your database, for every request. This is not a toy problem: in October 2015, Stripe lost one heavily used index in production (an operator removed it during a routine cleanup), the pool of API workers starved, and about two thirds of all API operations failed for roughly 90 minutes (Stripe’s postmortem). Database indexes explained covers what an index is, why column order decides whether yours gets used, and how to prove the plan changed.
2. The N+1 loop. The AI lists your orders, then fetches each order’s customer one at a time, because that is the clean way to write it. Ten orders means 11 queries; five hundred orders means 501 per page load, and the page times out. One join returns the same data in a single round trip. The N+1 query problem shows how to spot it (one request per row in the Network tab), the nested-select fix, and the three traps that bring it back, and the N+1 regression test keeps it fixed.
3. The “everything” query. Two habits hide here. First, select("*") with no LIMIT, fine while “everything” is 40 rows. Second, pagination with OFFSET: page 1 is instant, but page 200 makes the database read and discard thousands of rows before it can return your 25 (Use The Index, Luke explains this well). Always set a LIMIT, and for deep feeds use keyset pagination: WHERE id > last_seen_id LIMIT 25 for id order, or WHERE (created_at, id) < ($1, $2) LIMIT 25 for a newest-first feed, which is the common case.
4. Connection exhaustion. Postgres connections are heavy, and serverless functions open fresh ones constantly. Under a spike, the database spends its time refusing new connections while your app waits in line. Nothing is slow; everything is queued. Your plan’s connection limit is on Supabase’s compute and disk page, and the live count is one query in the SQL Editor: select count(*) from pg_stat_activity;. This is why Supabase ships a pooler (Supavisor on every project, PgBouncer on paid plans) that shares a small set of connections across many clients (Supabase docs); route serverless traffic through it, not direct connections.
The hand check: make the database show its work
Engineers do not guess at this. They ask the database to explain itself. On Supabase there are two shortcuts before you touch SQL: the Performance Advisor (Database, then Advisors) flags unindexed foreign keys in your project automatically, no SQL required (Supabase docs), and the Query Performance page ranks your slowest and most-called queries for you (Supabase docs). For the SQL itself, database indexes explained walks through reading EXPLAIN output: a Seq Scan on your biggest table and a five-figure Rows Removed by Filter are your missing index waving at you.
Prove it, one cause at a time
Each deep post above proves its fix with a runnable fail-then-pass test you can paste into an empty folder: the index post pins the query plan, the N+1 post counts the queries a page runs, and the regression test keeps both fixed. Run those, then write the same style of test against your own slow page, against the behavior the user sees, not the current implementation.
The prompt to paste
Audit this app for read performance at 100,000 rows per table. List every query that filters or sorts by a column with no index (foreign keys like user_id first), every query with no LIMIT, every loop that runs one query per item, and every OFFSET pagination. For each finding, give me the fix and the exact migration or code change. Do not change any code yet.
The fixes, in order
- Index every column you filter or sort by, foreign keys first. In Postgres:
CREATE INDEX CONCURRENTLY idx_orders_user_id ON orders (user_id);(theCONCURRENTLYkeeps the table usable while it builds). One catch: it cannot run inside a transaction, and Supabase runs each migration file in one, so apply it in the SQL Editor directly (or as its own manual step), not in a migration. Indexes are not free: each one makes writes a little slower, so index what you filter by, not every column; database indexes explained has the column-order rules. - LIMIT every list, and use keyset pagination for feeds that go deep.
- Kill N+1 loops with a join or one
INquery instead of a query per item. - Route serverless traffic through the pooler, not direct connections.
A cache is not on this list on purpose. Caching hides slow work instead of fixing it, so it comes after these fixes, not instead of them. When you get there, caching in plain English covers the one rule that matters.
Do all four and most weekend-project apps are fast again for a long time. If it is still slow after that, the problem is elsewhere, and the same rule applies: measure first, fix what the measurement names. This is one of the six things that break when your app meets real users, and two of them are already on the launch checklist.
The Get AI Native ebook goes deeper on this. It is free, and the expected launch is around Christmas. Join the waitlist on the homepage.