💙 Supporting healthcare non-profits: Metadataloop is free for 6–12 months. Contact Us to get started.
Developer Utility

Database Index & Constraint Advisor

Paste your CREATE TABLE schema — get heuristic index and constraint recommendations: unindexed foreign keys, missing primary keys, candidate unique constraints, and composite indexes for common filter/sort patterns.

Input · CREATE TABLE SQL
Recommendations
Recommendations will appear here.

Find missing indexes before they cause production slowdowns

Most ORMs and migration tools won't warn you when a foreign key column has no index, or when a table has no primary key at all. This advisor applies the same heuristics an experienced DBA would — scanning your schema for the patterns that reliably cause slow joins, slow deletes, and full table scans.

What it checks

  • Unindexed foreign keys: most databases do not automatically index FK columns — only the referenced side gets a unique index from the primary key.
  • Missing primary keys: every table should have one, for replication, upserts, and row-level addressing.
  • Candidate unique constraints: columns like email, username, or slug that look like natural keys but have no UNIQUE constraint.
  • Candidate filter columns: status, created_at, deleted_at and similar columns that are commonly used in WHERE/ORDER BY clauses.
  • Composite index opportunities: a foreign key combined with a date-like column — a common "latest records for this parent" query shape.

Common use cases

Pre-migration review

Catch missing indexes before a new table ships to production.

Code review helper

Paste a PR's migration diff and sanity-check the new schema in seconds.

Legacy schema audit

Run an inherited schema through the advisor to find quick wins.

Interview / learning aid

See the reasoning behind common indexing decisions, with explanations.

FAQ

Does this run against my real database? No — it's a static analysis of the CREATE TABLE text you paste. Nothing connects to a live database.

Are these recommendations guaranteed correct? They're heuristics based on common patterns, not query-plan analysis. Always validate with EXPLAIN/EXPLAIN ANALYZE on your actual workload before applying in production.

Why no index suggested on every column? Over-indexing slows down writes and wastes storage — the advisor only flags columns with a strong structural or naming signal.

⚠ Confirm Delete