duckdb benchmark, csv vs parquet vs native table

Small benchmark i did today with duckdb, nothing scientific, i just curious how slow csv really is for lookup query. I have skip-trace data, one column is phone number, and i want to find one number. Same query every time, only the format change.

select "PH: Phone1" from <source> where "PH: Phone1" = 6173353940;

Result from my laptop:

read_csv_auto('input.csv')         real 0.925s
read_parquet('skip-trace.parquet') real 0.016s
skip_trace (native duckdb table)   real 0.008s
skip_trace after create index      real 0.002s

duckdb benchmark screenshot

The full session if you want to see it, including the create index:

$ duckdb skip-trace
D select "PH: Phone1" from read_csv_auto('input.csv') where "PH: Phone1" = 6173353940;
Run Time (s): real 0.925
D select "PH: Phone1" from read_parquet('skip-trace.parquet') where "PH: Phone1" = 6173353940;
Run Time (s): real 0.016
D select "PH: Phone1" from skip_trace where "PH: Phone1" = 6173353940;
Run Time (s): real 0.008
D create index idx_phone_1 on skip_trace("PH: Phone1");
Run Time (s): real 0.069
D select "PH: Phone1" from skip_trace where "PH: Phone1" = 6173353940;
Run Time (s): real 0.002

What i take from this:

One caveat, this is one query on one machine, not a real benchmark suite. But i do this kind of lookup all day on skip-trace data, and the order of magnitude is consistent every time, so i stop bothering with csv after import.

- [ ] Ref: https://duckdb.org/docs/data/csv/overview
- [ ] Ref: https://duckdb.org/docs/stable/sql/indexes