Vibe Code Guardian
← All posts

Why Your AI-Built App Is Slow in Production (and What the AI Never Added)

The app worked in the preview because the database was nearly empty. Here are the performance gaps in AI-built apps: missing indexes, N+1 queries, no pagination, and what to fix first.

Aaron Allen·

Why Your AI-Built App Is Slow in Production (and What the AI Never Added)

The app was fine in the preview. You clicked through every screen and nothing took more than a second. You shipped it, and a week later a user asks why the dashboard takes eight seconds to load. You try it yourself. They are right.

Nothing changed in the code. What changed is how much data is in the database, and nobody was asked to make the app fast, so the AI never did. This post covers the performance gaps that show up in AI-built apps, why the AI leaves them out, and what to check before your users do the checking for you.

The preview hides slowness by design

A preview environment runs with a handful of rows in every table. Your app was tested against a database that had one user, two orders and three messages. Every query returned instantly because there was almost nothing to look through.

Once real users arrive, the same queries run against tables with thousands of rows. A query that took 20 milliseconds on ten rows can take two seconds on fifty thousand. The code is identical. The app is different.

The AI wrote code that was correct for the data it could see. It had no way to know your app would end up with more.

The gaps that reach production

No database indexes

This is the most common one and the easiest to fix. When the AI creates a table, it rarely adds indexes beyond the ones the platform creates automatically. Then it writes a query that filters by a column with no index on it.

Say the AI built an orders table and the dashboard shows "your recent orders" with a filter on user_id and a sort by created_at. With no index on those columns, Postgres reads the entire table to answer the question. At a thousand rows nobody notices. At fifty thousand rows the dashboard crawls.

How to check: open the Supabase dashboard, run your app, then look at the query performance view (Supabase has one under Database). The slowest queries will be listed. If a query filters or sorts on a column and the plan shows a sequential scan on a table with thousands of rows, an index is missing.

The fix is one line of SQL per column. It does not change any application code, and it can turn a two-second query into a few milliseconds.

N+1 queries

The AI writes a page that lists bookings, and for each booking it shows the customer's name. It fetches the bookings, then loops through them and fetches each customer one at a time. Fifty bookings means fifty-one database queries instead of one.

The app works. It is even readable code. It is just slow, and the slowness scales with your data.

How to check: in the browser's Network tab, count how many requests a page fires. Or watch the database connection count while you load one page. If one page load produces a burst of near-identical queries, you have found it.

The fix depends on your stack. With Supabase's client you use a single query with a nested select instead of a loop. Ask the AI to rewrite the fetch as one query that returns the related data, and show it the loop it wrote.

No pagination anywhere

You asked for an admin page listing "all orders". The AI wrote a query with no limit. In testing, that was forty orders. In production it is forty thousand, and the page tries to render all of them at once. The browser stalls and the database query takes longer than your hosting timeout.

Every list needs a limit and a way to move through pages. If you did not ask for pagination, the AI did not build it. Check every table view, every "recent activity" feed and every export.

File handling that only worked for small files

You tested uploads with a photo from your laptop. A user uploads a 40-megabyte scan. The request times out, the UI shows nothing, and the file never arrives.

AI-generated upload code rarely sets a sensible size limit, and rarely tells the user what the limit is. It also commonly processes the file in memory in a way that works at 2 MB and fails at 200 MB. Decide on a maximum size, enforce it before the upload starts, and say the limit next to the upload button.

Nothing is cached that could be

Every page load refetches the same data: the user's profile, the plan settings, the list of categories. None of it changed between requests, and the app asks the database for it every single time.

Caching is one of those things that adds complexity, so the AI does not add it unless you ask. It is usually the last gap to close, not the first. Sort out indexes and pagination first, then look at what you fetch most often and check whether any of it can safely live in memory for a few minutes.

Why the AI leaves these out

Performance work is invisible when it is done right. A feature demo shows a search box working. A demo never shows an index, and there is no prompt like "make sure the app still works with 100,000 rows" unless you think to write it.

There is also a mismatch in incentives. The AI is optimised to produce code that runs on the first try. The fastest code to write is often the slowest to run: loop over the records instead of one join, fetch everything instead of paginating. It is not wrong code. It is code that has not met your data yet.

What to do this week

Do not try to fix everything at once. Work down this list and stop when the app feels fast again.

  1. Load your slowest page with the Network tab open. Write down anything over 500 milliseconds.

  2. Check the Supabase query performance view and add an index for the worst query.

  3. Count requests per page. If one page fires dozens of near-identical queries, rewrite it as one.

  4. Open your biggest list page and check it has a limit.

  5. Upload your largest realistic file and watch what happens.

That is an afternoon, and it usually makes a bigger difference than another week of building features.

If you would rather someone else went through all of it, our launch-readiness audit covers performance alongside security and reliability, with a developer confirming every finding. Start with the free surface check at /free-check and see what is already visible from the outside, then look at the audit and monthly plans on /packages.

Want a developer to look at your app?

Built your app with AI tools? Run the free surface check yourself in a few minutes. Nothing to buy, and we never look at your app unless you run it.