In plain words
An index is a sorted lookup a database keeps for a column, so finding rows by that column means jumping straight to them instead of reading the whole table.
Where you see it
QuickBite's order history loaded instantly with 200 orders and takes six seconds with 200,000. Supabase's Performance Advisor flags foreign keys with no index, its Query Performance page lists your slowest queries, and explain analyze in the SQL Editor shows why each one is slow.
What goes wrong
- Assuming foreign keys come with an index
Postgres indexes primary keys on its own, but not the columns that point at other tables, like orders.customer_id. Those are often the columns every page filters by.
- Forgetting the column your access rules use
A row-level security policy such as auth.uid() = user_id runs on every query. Without an index on user_id, every page slows down as the table grows.
- Indexing every column to be safe
Each index is updated on every insert and update, and takes disk space. Add them for queries you actually run, and check they get used.
What to tell your agent
Quick check
Sign in to earn +10 XP for itGuildhall's member list took 0.1 seconds at launch and takes 5 seconds now, with 300,000 members. The query filters by guild_id. Likely fix?