Database Index
Queries were instant with a few rows, but with tens of thousands of orders the page spins—AI says to add an index. What does that mean?
user_id slows down until an index lets the database jump straight to matching rows. Indexes are not free: every extra index must be updated on inserts and edits, so indexing every column slows down writes and uses extra storage.You can say this to an AI Agent
Ready to paste into Cursor, Claude Code, or CodexThe endpoint that fetches a user's recent orders slowed down as data grew. Run `EXPLAIN ANALYZE` first to check if it is doing a full table scan, then add a migration with a database index matching the actual `WHERE` and `ORDER BY` columns without indexing unused fields. Run `EXPLAIN ANALYZE` again to compare scanned rows and latency.
