🔧 Unbreak My AppAll fixesFix KitsSponsor

Fixes › Performance

App is slow: dozens of database calls per page (N+1 queries)

LovableBoltCursorv0

The error

Page takes 3–10s; network tab shows many identical requests

Why it happens

The AI-generated code fetches a list, then fetches related data separately for each item, often inside useEffect with no caching, and re-runs on every render.

How to fix it

  1. Fetch related data in one query (Supabase: select('*, author:profiles(name)')).
  2. Add indexes on foreign keys and columns you filter by.
  3. Paginate lists (.range()).
  4. Cache with React Query/SWR and fix useEffect dependency arrays.

Fix prompt (paste into Lovable, Bolt, Cursor, Replit or v0)

This page is slow because it makes many database requests. Find N+1 query patterns and replace them with single queries using joins/embedded selects, add pagination, add indexes for the columns we filter and join on (give me the SQL), and use React Query/SWR so data isn't refetched on every render.

FAQ

How do I spot it?

Open DevTools → Network and count requests on page load.

Do indexes help with RLS?

Yes, index columns used in policies, like user_id.

Related fixes

Want the full checklist for this area? Get a Fix Kit ($29)

Get one new fix a week

Free newsletter: the newest breakages in Lovable, Bolt, Cursor, Replit and v0 apps, with paste-in fixes.

We only use your email to send the newsletter. Unsubscribe any time. See privacy.