Skip to content

Menu

Index Advisor

Suggest indexes from SQL queries

Runs entirely in your browserDatabaseFree, no sign-up
Loading tool

01What is Index Advisor?

A slow query usually has an obvious suspect, and it is often a missing index. This advisor reads one SELECT statement and proposes CREATE INDEX statements you can test. It does this with pattern matching on the query text, so there is no database connection involved and the SQL stays in your browser. The first pass removes comments and blanks out string literals. That way a word inside 'quoted text' is never mistaken for a column. Next it maps every table after FROM and JOIN to its alias, such as orders o or customers AS c. Qualified columns then land on the right table. In the WHERE clause it collects columns compared with =, IN, IS NULL, <, >, BETWEEN or a LIKE prefix. These are grouped per table. Each composite index puts equality columns first and range columns last, which is the order the PostgreSQL docs on multicolumn indexes say a B-tree can use well. Conditions with != or NOT IN are skipped, since they rarely benefit from an index. A JOIN ... ON condition gets an index on the joined table's column. ORDER BY and GROUP BY columns are appended after that table's equality filters. Sorting by a SELECT alias such as cnt is ignored. A couple of special cases get their own treatment. LOWER(email) = ... produces an expression index. A leading-wildcard search like LIKE '%@gmail.com' produces a pg_trgm GIN index, plus the CREATE EXTENSION line it needs. Subqueries in parentheses are analysed on their own. Duplicate suggestions are merged, and an index that is just the leading part of a longer suggestion on the same table is dropped. Here is a typical run. For SELECT * FROM orders WHERE customer_id = 42 AND status = 'paid' ORDER BY created_at DESC, you get one statement: an index on orders (customer_id, status, created_at). The two equality filters come first, so rows can come back already sorted. The SQL is written in PostgreSQL syntax, and reserved names like user are double-quoted. Plain B-tree statements also run on MySQL and SQLite. Keep in mind this is text analysis, not a query planner. It cannot see row counts, data distribution or the indexes you already have, and primary keys are indexed anyway. Treat every suggestion as a candidate and confirm it with EXPLAIN ANALYZE before it goes into a migration.

Backend developers and DBAs who want quick candidate indexes for a slow PostgreSQL or MySQL query before testing them with EXPLAIN ANALYZE. The tool runs entirely in your browser, so your data never leaves your device.

02How to use Index Advisor

  1. Paste one query into the SQL Query box, or load the JOIN query, Aggregate query or Subquery example.
  2. Read the index suggestions, each tagged with its priority, table and index type.
  3. Check each reason line to decide whether it fits your data and workload.
  4. Click Copy All to copy every CREATE INDEX statement at once.
  5. Test the indexes with EXPLAIN ANALYZE on a copy of production data before adding them to a migration.

03Worked examples

Input: SELECT * FROM orders WHERE customer_id = 42 AND status = 'paid' ORDER BY created_at DESC
Result: [low] orders (btree) CREATE INDEX idx_orders_customer_id_status_created_at ON orders (customer_id, status, created_at);
The shorter WHERE-only index is a prefix of this one, so it is dropped and only the combined index remains.
Input: SELECT id FROM users WHERE email LIKE '%@gmail.com'
Result: [medium] users (gin) CREATE EXTENSION IF NOT EXISTS pg_trgm; CREATE INDEX idx_users_email_trgm ON users USING gin (email gin_trgm_ops);
A leading wildcard cannot use a B-tree, so a trigram GIN index is suggested instead.
Input: SELECT * FROM products WHERE name LIKE 'Mac%'
Result: [medium] products (btree) CREATE INDEX idx_products_name ON products (name);
The reason line adds that PostgreSQL needs text_pattern_ops or the C collation for this to be used.
Input: SELECT u.name, COUNT(*) FROM users u JOIN orders o ON o.user_id = u.id WHERE o.created_at > '2026-01-01' GROUP BY u.name
Result: [medium] CREATE INDEX idx_orders_created_at ON orders (created_at); [high] CREATE INDEX idx_orders_user_id ON orders (user_id); [medium] CREATE INDEX idx_users_name ON users (name);
Aliases resolve to table names. users.id gets no suggestion because primary keys are already indexed.
Input: SELECT * FROM users WHERE LOWER(email) = '[email protected]'
Result: [medium] users (btree) CREATE INDEX idx_users_lower_email ON users ((lower(email)));
An expression index matches the LOWER() call. MySQL 8.0.13 and later accept the same double parentheses.
Input: SELECT * FROM "user" WHERE status = 'x' AND created_at BETWEEN '2026-01-01' AND '2026-02-01'
Result: [high] user (btree) CREATE INDEX idx_user_status_created_at ON "user" (status, created_at);
user is a reserved word in PostgreSQL, so the table name is quoted. The BETWEEN range column goes last.

04Common use cases

  • Getting a starting point for a slow reporting query that showed up in pg_stat_statements
  • Reviewing ORM-generated SQL from Django, Rails or Prisma for missing foreign key indexes
  • Preparing for a code review on a migration that adds new query patterns
  • Spotting leading-wildcard LIKE searches that a normal B-tree cannot help with
  • Checking that a case-insensitive login lookup on LOWER(email) has a matching expression index
  • Teaching a junior developer how WHERE, JOIN and ORDER BY map onto composite index column order

05Tips

  • Qualify columns in multi-table queries (o.status, not status). Unqualified columns are assigned to the first table in FROM, and the reason line says so.
  • In PostgreSQL, LIKE 'abc%' only uses a B-tree built with text_pattern_ops or the C collation. The reason line flags this when it applies.
  • Use CREATE INDEX CONCURRENTLY on large production Postgres tables so writes are not blocked while the index builds.
  • A low-selectivity column such as a boolean active flag rarely pays off as an index by itself.
  • Every index costs write time and disk. When two suggestions share leading columns, one composite index may cover both.

06Related concepts

B-tree index, composite index, query planner, EXPLAIN ANALYZE, trigram index.

Frequently Asked Questions

What is Index Advisor?

Index Advisor is a free, browser-based developer tool on AIDToolStack. Suggest indexes from SQL queries It requires no installation or sign-up and works entirely in your browser.

Is Index Advisor free to use?

Yes. No sign-up, no fees and no usage cap.

Does Index Advisor store my data?

No. It runs in your browser; nothing is uploaded.

Cheat sheet

Reviews and commentsShow

Reviews

Sign in to leave a review.

Loading reviews…

Comments

Sign in to leave a comment.

Loading comments…

What changed in AI dev tools, once a month

Renames, shutdowns, pricing changes and new MCP setups, each with a source.

Subscribe