'SQLite identify missing index

Could you tell me please if it is possible to identify missing indexes for a select query using SQLite database?

Or is there any tool that can help?

Thank you!



Solution 1:[1]

Use EXPLAIN QUERY PLAN command to identify missing index for given SQL query. For example, the following result indicates you may need an index for a in table t1.

sqlite> EXPLAIN QUERY PLAN SELECT a, b FROM t1 WHERE a=1;
SCAN TABLE t1

If you have a lot of SQL queries and want to quickly identify missing index, I wrote a tool which helps analyze many SQL queries and saves you much time in the repeating process.

Solution 2:[2]

Using the sqlite3 command line tool, first enter

.expert

And then run your query as normal.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rod Chen
Solution 2 Stu