Commit 9bfdb60
committed
Optimize subtree delete lookup
Replace the subtree LIKE predicate with exact-root and bounded child range deletes so SQLite can use the (scan_id, path) primary key instead of scanning every row in the scan.
Benchmarks on the real 7.07M-entry / cache showed old LIKE predicates taking ~17-23s regardless of subtree size, while the new range predicate scaled with subtree size: /Applications ~18.0s -> ~0.85s, /System ~17.7s -> ~0.73s, /Library ~20.7s -> ~0.27s, /opt ~21.4s -> ~0.07s, /private ~18.9s -> ~0.02s, /bin ~22.2s -> ~0.02s. /Users, which covers most of the scan, improved ~20.8s -> ~16.0s.
A synthetic actual DELETE benchmark with 1,001,001 rows deleting a 1,001-row subtree improved from ~114ms to ~19ms.1 parent 86f71f7 commit 9bfdb60
1 file changed
Lines changed: 20 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
307 | 307 | | |
308 | 308 | | |
309 | 309 | | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
314 | 330 | | |
315 | 331 | | |
316 | 332 | | |
| |||
0 commit comments