COUNT(*) is ~1.81× faster than COUNT(score)
Counter-intuitive but consistent: `COUNT(*)` is 1.8× faster. It only counts rows, while `COUNT(col)` reads values and checks for NULL.
Result
| Run | COUNT(*) | COUNT(score) | Ratio |
|---|---|---|---|
| Run 1 | 4.352 | 8.112 | 0.54× |
| Run 2 | 3.772 | 6.839 | 0.55× |
| Run 3 | 3.804 | 6.718 | 0.57× |
Spread over 3 runs: COUNT(*) CV 7.0% / COUNT(score) CV 9.2% / Ratio CV 2.1%
The statement
SELECT COUNT(*) FROM items; SELECT COUNT(score) FROM items; Conditions
100,000 rows; `score` is NOT NULL.
Where this number does not apply
If the column is indexed and nullable-free, SQLite may walk only the index and the gap narrows.
Reproduce
cd bench && python sqbench.py --samples 9 --out ../data/run.json