Giving the planner statistics in SQL
The planner guesses row counts. ANALYZE replaces the guess with a measurement.
ANALYZE;
SELECT
tbl AS table_name,
idx AS index_name,
stat
FROM sqlite_stat1
ORDER BY tbl, idx;
How it works
ANALYZEwrites row and index statistics intosqlite_stat1.- Re-run it after the data's shape changes, not after every write.
- Reading
sqlite_stat1shows you what the planner now believes.
Keywords and builtins used here
ANALYZEASBYFROMORDERSELECTtable_name
The run, in numbers
- Lines
- 8
- Characters to type
- 96
- Tokens
- 20
- Three-star pace
- 90 tpm
At the three-star pace of 90 tokens a minute, this run takes about 13 seconds.
Step 2 of 2 in Reading a plan, step 2 of 17 in Plans & performance.