sqlite3.Row is ~1.09× slower than tuple (default)
Setting `row_factory=Row` makes fetching 20,000 rows ~9% slower — the cost of name-based access.
Result
| Run | sqlite3.Row | tuple (default) | Ratio |
|---|---|---|---|
| Run 1 | 27.690 | 24.569 | 1.13× |
| Run 2 | 26.866 | 25.301 | 1.06× |
| Run 3 | 26.685 | 24.399 | 1.09× |
Spread over 3 runs: sqlite3.Row CV 1.6% / tuple (default) CV 1.6% / Ratio CV 2.4%
The statement
con.row_factory = sqlite3.Row
rows = con.execute('SELECT id,name,score FROM items LIMIT 20000').fetchall() rows = con.execute('SELECT id,name,score FROM items LIMIT 20000').fetchall() Conditions
20,000 rows fetched with `fetchall()`, three columns.
Where this number does not apply
With few rows the difference is lost in noise.
Reproduce
cd bench && python sqbench.py --samples 9 --out ../data/run.json