← All notes

SQLite indexes and the query planner

Answer:

CREATE INDEX idx_fruit_state ON fruitsforsale(fruit, state);

EXPLAIN QUERY PLAN
SELECT price FROM fruitsforsale WHERE fruit = 'Orange' AND state = 'CA';
-- SEARCH fruitsforsale USING INDEX idx_fruit_state (fruit=? AND state=?)

Index tips

Run ANALYZE so the planner has statistics.

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: SQLite (sqlite.org), Query Planning, Public domain (sqlite.org); SQLite (sqlite.org), CREATE INDEX, Public domain (sqlite.org).

Cite this

Permanent ID: iil:note:e3adge9v

iinventedlight. 2026. "SQLite indexes and the query planner." iinventedlight Library, iil:note:e3adge9v, version of 2026-11-04. https://iinventedlight.com/library/notes/sqlite-query-planner-indexes/. License: CC-BY-4.0.

@misc{iil_note_e3adge9v,
  author = {{iinventedlight}},
  title = {{SQLite indexes and the query planner}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-04},
  url = {https://iinventedlight.com/library/notes/sqlite-query-planner-indexes/},
  note = {Permanent ID iil:note:e3adge9v. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.

For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/sqlite-query-planner-indexes.md.