Your app worked fine with ten test records. Now it has real users and real data, and every page takes three seconds to show anything. That is normal for apps built quickly with Lovable, Bolt, Cursor or v0: the code was written to work, not to work with 10,000 rows on a phone over 4G. The good news is that slowness almost always comes from a handful of causes, and most of them are cheap to fix once you know which one you have.
Short answer: measure before you change anything. In most AI-built apps the time goes to the database (too many small queries, missing indexes, security rules that run per row), to loading everything at once, or to large images. Fix the biggest measured cause first; it is often a one-line change.
Measure first: 10 minutes
- Run PageSpeed Insights on your slowest page, mobile tab. Look at Largest Contentful Paint (good is 2.5 seconds or less): how long until the main content shows. The report also names your heaviest images and scripts.
- Open the page in Chrome with DevTools, Network tab, throttling set to "Fast 4G". Reload. Sort by time. Count the requests to your database or API: if one page makes 30 or 100 of them, you have found your problem.
- Check the database's own report. Supabase has Query Performance and a Performance Advisor in the dashboard; Neon has a monitoring page. Both show which queries take the most total time.
- Write down three numbers (page load, number of requests, slowest query) so you can tell whether a fix helped.
1. One query per item (the N+1 problem)
The page loads a list of 50 orders, then asks the database for each order's customer, one by one: 51 round trips instead of 1. AI-generated code does this a lot because each component fetches its own data. On a phone, every round trip adds tens to hundreds of milliseconds.
Fix: fetch related data in one query. In Supabase that is an embedded select, for example select('*, customer(*)'); in plain SQL it is a join. Then pass the data down to the components instead of letting each one fetch.
2. No index on the columns you filter by
Postgres does not create indexes on foreign key columns for you. Without an index, "all orders for this user" reads the whole table. With 100 rows nobody notices; with 100,000 rows every page waits.
Fix: add an index on every column you filter or join on: user_id, created_at if you sort by it, foreign keys. Supabase's Performance Advisor lists unindexed foreign keys for you. A search box that uses ILIKE '%word%' can't use a normal index at all; see slow or missing search in your AI-built app.
3. Security rules that run once per row
In Supabase, row level security (RLS) policies decide which rows a user may see. A policy like user_id = auth.uid() can call auth.uid() for every row it checks. Supabase's RLS guide gives three performance rules:
- wrap the function in a select,
(select auth.uid()), so Postgres computes it once per query "rather than calling the function on each row"; - index every column a policy filters on, because "an unindexed filter column turns a read into a sequential scan";
- name the role with
to authenticated, so the policy doesn't even run for visitors who aren't signed in.
Do not fix slowness by switching RLS off. That trades a speed problem for a data leak.
4. The page loads everything before it shows anything
Typical signs: a dashboard that downloads every record to count them in the browser, a list without pagination, or a blank screen until all data has arrived.
Fix: count and sum in the database, not in the browser. Load 20 or 50 rows at a time. Show the page frame straight away and fill in the data as it arrives. For public pages that search engines should read, render them on the server or prerender them, so visitors see content before the JavaScript has finished.
5. Images straight from the phone camera
A 4 MB photo shown as a 300-pixel thumbnail is still a 4 MB download. PageSpeed Insights will name these files.
Fix: resize images when they are uploaded, serve WebP or AVIF, set width and height so the page doesn't jump, and add loading="lazy" to images below the fold. Netlify and Vercel can resize images on the fly, and so can Supabase Storage on paid plans. For upload limits, storage rules and costs, see file uploads in an AI-built app.
6. Cold starts: the first visitor waits
Serverless databases and functions go to sleep when nobody uses them. Neon, for example, scales to zero after 5 minutes of inactivity and starts again "within a few hundred milliseconds". Serverless functions have a similar first-request delay. For a small app this is usually fine and saves money. It becomes a problem when one page triggers several cold pieces in a row.
Fix: first check whether cold starts are really your problem (the first load is slow, the second fast). If they are, cut the chain of calls per page, or pay for an always-on database only for the app that needs it. Don't keep everything awake "just in case"; that is a monthly bill for a few hundred milliseconds.
7. Waiting for slow outside services
Calls to an AI model, a payment provider or an email service can take seconds. If the page waits for them before responding, the user waits too.
Fix: stream long AI answers so text appears as it is written, send emails and other follow-up work in the background, and set a timeout with a clear message instead of a spinner that never stops. Cache answers that don't change, such as a product description generated once.
What to fix first
- Dozens of requests per page: start with 1 (N+1), then 4 (pagination).
- Few requests, but each one slow: start with 2 (indexes) and 3 (RLS).
- Slow even when empty: look at 5 (images) and your JavaScript size in PageSpeed Insights.
- Only the first load is slow: 6 (cold starts).
- One action hangs, the rest is fine: 7 (outside services).
After each fix, measure the same three numbers again. If a change didn't move them, undo it: speed work without measuring tends to add complexity and no speed.
Expecting a rush of visitors? Getting ready for a launch-day spike covers connections, timeouts and email limits.
Want someone to find it for you?
I look at apps built with Lovable, Bolt, Cursor or v0 and fix what slows them down, starting with a measured list of causes so you know what you are paying for. Read fix it or rebuild it if you are not sure your app is worth fixing, or send me the link on the hire page and I'll reply within 24 hours.