LovableCursorBoltReplit

How to Fix an AI-Built App That Is Slow Under Real Load

Your app feels fast in the editor and dies under real users. The actual performance fixes for AI-built apps.

TL;DR

The biggest performance issues in AI-built apps are: missing database indexes, fetching too much data in API routes, no caching layer, and rendering everything client-side. Fix these in order; the database fixes alone usually solve 80 percent of slowness.

What is actually happening

AI tools optimize for code that works, not code that scales. The default patterns generate are fine for 10 users and fall apart at 100. The performance issues compound: a slow query causes a slow page, which keeps the user's browser open longer, which holds open more database connections, which makes the next query slower.

The fix, in order

Try these in sequence. Most apps are fixed by the first or second step.

  1. 1

    Find and add the missing database indexes

    In Supabase, go to Database then Query Performance. Look at the slowest queries. For each one, identify the columns in the WHERE clause and add an index. Run: CREATE INDEX idx_table_column ON public.table_name(column_name); This single step usually drops query times from seconds to milliseconds.

  2. 2

    Stop fetching all the data when you only need some

    AI-generated code often does .select('*') on every query. Replace with .select('only,the,columns,you,need'). Also: if you are paginating, use .range(start, end) instead of fetching all rows and slicing in JavaScript.

  3. 3

    Cache the things that do not change often

    If your app calls the same API route 100 times to get the same data, add caching. In Next.js, use 'export const revalidate = 60' on the route or fetch with { next: { revalidate: 60 } } to cache responses for 60 seconds. For static data, set revalidate = 3600 or longer.

  4. 4

    Move work to the server where it belongs

    AI tools love client components because they are easier to scaffold. But anything that fetches data, does heavy computation, or queries a database should be a server component or server action. Look for 'use client' directives and move data-fetching logic out of them.

  5. 5

    Run Lighthouse and fix the top three issues

    In Chrome DevTools, open the Lighthouse tab and run a Performance audit on a deployed page. Lighthouse gives you specific issues with specific fixes. Focus on the top three: usually they are unoptimized images, render-blocking JS, and bad LCP (largest contentful paint).

When to stop debugging and get help

If you have done all five steps and the app is still slow, the issue is architectural. The data model, the way components render, or the request waterfall are all wrong. These need a real review, not more hot fixes.

Stuck after trying these?

We do a $100 Quick Audit that pinpoints exactly what is wrong, why, and what it will take to fix. No sales call gating, no fluff.

Start a $100 Audit

Related fixes

Not sure exactly what is broken? Run a free scan and get a diagnosis in under 2 minutes.