Missing database indexes on common lookup fields
An index is a precomputed lookup table that lets the database find rows by a specific column in milliseconds instead of scanning the whole table. Forgetting one is invisible at 10 users and crippling at 10,000.
#What goes wrong
AI tools usually mark primary keys correctly but rarely add indexes for foreign keys, unique fields like email, or fields you filter on often. The schema looks fine in code review. The performance problem only shows up under load, weeks or months later.
#Why it matters
A missing index on a user lookup means every request scans the entire users table. With ten rows that is fine. With a million rows the request takes seconds. Most performance crises in production apps trace back to a missing index, not bad code.
#How Heimdall checks for this
Heimdall reads your Prisma schema or Drizzle definitions and looks for foreign keys, common lookup fields like email or slug, and fields referenced in unique constraints that lack an explicit index. Each gap is reported as a warning with the field and the table.
#How to fix it
In Prisma, add @@index([field]) or mark the field @unique. In Drizzle, use the index() helper in the table definition. Run a migration and verify the index was created with EXPLAIN on a typical query.
Frequently asked questions
Does Prisma create indexes automatically?
Will adding an index slow down writes?
Should I index every column?
Run this check on your own repo
Heimdall scans your GitHub repo for this and 16 other issues in under a minute.
