Skip to main content

SQL Index Advisor

Paste a SQL SELECT query and get CREATE INDEX suggestions. The advisor analyzes WHERE, JOIN ON, and ORDER BY clauses to recommend single-column and composite indexes.

✓ WHERE / JOIN / ORDER BY analysis ✓ Composite index suggestions ✓ Runs 100% in your browser

Frequently Asked Questions

How does this tool suggest indexes?▼

The advisor parses your SELECT query and identifies columns used in WHERE clauses (equality, range, LIKE), JOIN ON conditions, and ORDER BY clauses. It suggests single-column indexes for individual conditions, composite indexes when multiple columns on the same table appear in WHERE, and notes ORDER BY columns that benefit from indexing.

What is a composite index and when should I use it?▼

A composite index covers multiple columns in a defined order. Use it when your WHERE clause filters on multiple columns from the same table — the database can use one composite index instead of scanning separate single-column indexes. The most selective column (smallest cardinality) should typically come first, with range columns last.

Why should I index foreign key columns?▼

Foreign key columns used in JOIN ON conditions cause full table scans if unindexed — the database must scan every row of the joined table to find matches. An index on the foreign key column turns this into an index lookup, reducing JOIN cost from O(n) to O(log n).

What is the cardinality rule for composite indexes?▼

Put higher-cardinality columns (more unique values) first in composite indexes. For example, if filtering by country (low cardinality, ~250 values) and user_id (high cardinality, millions of values), the index should be (user_id, country) for queries that filter on user_id, or (country, user_id) for queries filtering on country first.

How many indexes is too many?▼

Every index adds overhead to INSERT, UPDATE, and DELETE operations because the database must update all indexes on write. As a rough guideline, 3–5 indexes per table is a reasonable range for OLTP workloads. Profile actual query performance with EXPLAIN ANALYZE before adding indexes in production.

Does this tool send my SQL to a server?▼

No. All analysis runs entirely in your browser using JavaScript. Your SQL never leaves your machine.

Share this tool: X / Twitter LinkedIn
✓ 60,000+ developers use DevPlaybook ★★★★★ 4.8 / 5 on Gumroad ✓ MIT licensed · Instant download ✓ No login required

Related Products

on Gumroad

You Might Also Need

More Free Tools

Enjoying this tool? Get more like it.

Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.

DevPlaybook Pro 7 days free

Unlock AI-Powered Dev Tools

  • ⚡ AI Code Review, Doc Generator & SQL Builder
  • ⚡ All premium templates & early access
  • ⚡ Member discounts on Gumroad products
Start Free Trial →

$9/mo after trial · Cancel anytime

Want the full toolkit?

Get DevPlaybook Pro

Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.

$79
$241 separately Save $162 (67% off)
Get DevPlaybook Pro — $79 →

MIT licensed · Instant download · No subscription

See what's included → Browse all deals →