Commit 53b70fe
perf(planner): read a covering index for a no-seek WHERE scan
When a query's `WHERE` seeks no index (no equality/range on any index's leading
column), SQLite still reads from a covering secondary index if one holds every
column the query references — both projected and `WHERE`-tested — and is narrower
than the table, filtering in the index (`SCAN t USING COVERING INDEX <ix>`)
rather than scanning the table. graphite previously declined any covering scan
once a `WHERE` was present.
`covering_scan` now handles the `WHERE` case, gated so it never steals the
`SEARCH` path: it applies only when `eqp_access` would render a bare `SCAN`
(i.e. no seek). This keeps the plan renderer and the executor in lockstep — the
EQP chain consults `covering_scan` before the seek renderer, while the executor
reaches it only after its own seek attempts fail. Column coverage already
includes the `WHERE` clause, and the same strictly-narrower width test applies.
The covered scan's row order (index order) matches SQLite. Verified plan and rows
against sqlite3 3.50.4 (`tests/eqp_covering_scan_where.rs`), including seekable
`WHERE`s correctly staying `SEARCH`.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent e91ae0d commit 53b70fe
2 files changed
Lines changed: 83 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17895 | 17895 | | |
17896 | 17896 | | |
17897 | 17897 | | |
17898 | | - | |
| 17898 | + | |
17899 | 17899 | | |
17900 | 17900 | | |
17901 | 17901 | | |
17902 | 17902 | | |
17903 | 17903 | | |
| 17904 | + | |
| 17905 | + | |
| 17906 | + | |
| 17907 | + | |
| 17908 | + | |
| 17909 | + | |
| 17910 | + | |
| 17911 | + | |
| 17912 | + | |
| 17913 | + | |
| 17914 | + | |
| 17915 | + | |
| 17916 | + | |
| 17917 | + | |
| 17918 | + | |
| 17919 | + | |
17904 | 17920 | | |
17905 | 17921 | | |
17906 | 17922 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
0 commit comments