SQL BenchMEASURED, NOT GUESSED

    ↑↓ to select, Enter to open, Esc to close

    SELECT * is ~1.68× slower than SELECT id, score

    When you return 2,000 rows, selecting only two columns is 1.7× faster — the cost is carrying the 40-character `payload`.

    Result

    RunSELECT *SELECT id, scoreRatio
    Run 14.2952.5551.68×
    Run 23.7222.2241.67×
    Run 33.6942.0241.82×

    Spread over 3 runs: SELECT * CV 7.4% / SELECT id, score CV 9.8% / Ratio CV 4.1%

    SELECT *: 4.29msSELECT id, score: 2.56msRun1SELECT *: 3.72msSELECT id, score: 2.22msRun2SELECT *: 3.69msSELECT id, score: 2.02msRun3

    The statement

    SELECT * FROM items LIMIT 2000;
    SELECT id, score FROM items LIMIT 2000;

    Conditions

    100,000 rows; both queries are pinned with `LIMIT 2000`.

    Where this number does not apply

    On narrow tables, or when you fetch a few dozen rows, the gap nearly vanishes.

    Reproduce

    cd bench && python sqbench.py --samples 9 --out ../data/run.json