SQL Index Advisor
Find which indexes your slow queries are missing, in which column order, which existing indexes overlap, and get a migration script for PostgreSQL, MySQL, SQLite or SQL Server.
ブラウザ内で動作します。ファイルは端末の外に出ません。 確認方法を見る
…
使い方
- 1Paste the schema
Add CREATE TABLE and CREATE INDEX statements, or open a .sql dump.
- 2Paste the queries
Add the slow or frequent queries, separated by semicolons.
- 3Pick the database
Choose PostgreSQL, MySQL, SQLite or SQL Server and the covering column limit.
- 4Read the suggestions
Each index lists the reason and the queries it helps.
- 5Review warnings
Open Per query to see the parsed columns and notes on LIKE, functions and OR.
- 6Export the script
Copy or download the migration script with CREATE lines and commented DROP hints.
このツールについて
Most slow pages in a database-backed application come down to a query that scans a whole table because no index matches its filter and sort. The fix is usually one composite index, but choosing it well takes experience. Which columns go first? Does the existing index on customer_id already help? Will an index on a column wrapped in LOWER() be used at all? This advisor reads the CREATE TABLE and CREATE INDEX statements of your schema and the SELECT, UPDATE and DELETE statements you run, and works through each query the way a database planner looks at it. It resolves table aliases, finds columns compared with = or IN, columns used in JOIN conditions, range conditions such as >, BETWEEN and LIKE with a fixed prefix, and the ORDER BY and GROUP BY columns. From those it proposes one index per table and query, ordered by a widely used rule of thumb: equality columns first, then the sort columns, then a single range column.
Why that column order
A B-tree index can jump straight to rows that match equality conditions on its leading columns. If the next columns are the ORDER BY columns, the matching rows are already sorted and the database can stop after LIMIT rows without sorting. A range condition, by contrast, ends the useful part of the index: columns after the first range column can only be checked row by row. The advisor therefore places one range column last and tells you when other range columns will be filtered afterwards. Suggestions that are a left prefix of a longer suggestion for the same table are merged into the longer one.
Existing indexes
Primary keys, UNIQUE constraints, inline KEY definitions, CREATE INDEX and ALTER TABLE ... ADD INDEX are all read. If an existing index already starts with the needed columns, the query is reported as served. Two kinds of redundancy are flagged: indexes with identical columns, and a non-unique index that is a left prefix of another index, such as (customer_id) next to (customer_id, status). Indexes that none of the pasted queries could use are listed separately, with a reminder that code you did not paste may still need them.
Warnings it gives
LIKE patterns that begin with % cannot use an ordinary B-tree index, columns wrapped in a function in the WHERE clause need an expression index, OR-only conditions are better served by separate indexes, and ORDER BY with mixed ASC and DESC needs the same mix in the index. For PostgreSQL and SQL Server, columns that are only selected can go into an INCLUDE list to make a covering index.
Limits
This is a static, heuristic review, not a planner. It does not know table sizes, data distribution or selectivity, so an index on a column with two values may be suggested even though a scan is faster. Subqueries, views, CTE bodies and dynamic SQL are only partly understood. Always compare EXPLAIN plans before and after, and create indexes on a large production table at a quiet time or with CONCURRENTLY or ONLINE options.
計算例
A shop has customers and orders tables and three indexes on orders: (customer_id), (customer_id, status) and (total). Four queries are pasted. For the recent paid orders page, WHERE status = 'paid' AND created_at >= '2026-10-01' ORDER BY created_at DESC, the advisor proposes (status, created_at) with INCLUDE (id, total) on PostgreSQL. For the customer screen it proposes (customer_id, created_at), noting that the existing customer index only serves the equality part. It flags (customer_id) as a left prefix of (customer_id, status), reports (total) as unused by these queries, and warns that LIKE '%rahman%' on customers.name needs full-text or trigram search.
ポイント
- カテゴリ: 開発・データ
- ブラウザ内で動作し、登録もアップロードも不要です。
- 入力した情報は端末内にとどまります。
- 英語で利用できます。
- 内容の最終確認日:
- 公式情報源: PostgreSQL, MySQL and SQLite documentation on multicolumn indexes and the query planner
よくある質問
Which databases does it support?
It reads standard CREATE TABLE and CREATE INDEX syntax and writes statements for PostgreSQL, MySQL and MariaDB, SQLite and SQL Server, quoting names the way each one expects.
Why is equality before sort before range?
Equality columns narrow the index to one sorted slice, sort columns let the database read that slice in order, and a range column can only be used once because it ends the ordered part.
Should I create every suggested index?
No. Each index costs disk space and slows inserts and updates. Start with the queries that are slow in your logs and confirm the improvement with EXPLAIN.
Why is a column with LOWER() not indexed?
An index on email stores the original values, so a filter on LOWER(email) cannot use it. Create an expression index on LOWER(email) or store a normalised column.
Can I drop the indexes it calls redundant?
Usually a left-prefix duplicate can go, but check that it is not backing a foreign key or unique rule, and that no other code depends on its name.
Is my schema sent to a server?
No. Everything is parsed in your browser, and the last schema and queries are saved only in local storage.
