Section: Inspect query plans

Rebuild indexes

sql
sql
REINDEX;
Explanation

Useful after collation changes or when rebuilding index structures.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Inspect query plans
Explain a query plan
See whether SQLite scans or uses an index.
OpenIn sheetsqlsame section
Collect statistics with ANALYZE
Help the planner choose better indexes.
OpenIn sheetsqlsame section
Run PRAGMA optimize
Let SQLite perform lightweight maintenance.
OpenIn sheetsqlsame section
Enable automatic EXPLAIN QUERY PLAN in shell
Show plans before each entered statement.
OpenIn sheettextsame section
Create a basic index
Index a frequently filtered column.
OpenIn sheetsql1 tag match
Create a composite index
Index multiple columns in query order.
OpenIn sheetsql1 tag match