skip to content
Pradeep Chhetri

Software Engineer. Writing about databases, infrastructure, and distributed systems.

Main navigation

  • Home
  • Blog
  • TIL
GitHub LinkedIn RSS

SQLite: Index Recommendations

October 4, 2020 · TIL

Tags:
  • sqlite
  • index

For databases, most of the read performance depends on indexing. SQLite has expert command which recommends the appropriate index creation based on the query.

sqlite❯ CREATE TABLE x1(a, b, c);                  -- Create table in database 
sqlite❯ .expert
sqlite❯ SELECT * FROM x1 WHERE a=? AND b>?;        -- Analyze this SELECT 
CREATE INDEX x1_idx_000123a7 ON x1(a, b);

0|0|0|SEARCH TABLE x1 USING INDEX x1_idx_000123a7 (a=? AND b>?)

sqlite❯ CREATE INDEX x1ab ON x1(a, b);             -- Create the recommended index 
sqlite❯ .expert
sqlite❯ SELECT * FROM x1 WHERE a=? AND b>?;        -- Re-analyze the same SELECT 
(no new indexes)

0|0|0|SEARCH TABLE x1 USING INDEX x1ab (a=? AND b>?)

© 2026 Pradeep Chhetri