v2.0 alpha, Windows: query ~12x slower when stdout is redirected to NUL (progress bar)
What happens?
On Windows, with the DuckDB v2.0 alpha CLI, a query whose output is redirected to NUL runs about 12x slower than the same query piped or with the progress bar disabled. DuckDB 1.5.5 does not show this.
To Reproduce
Any large CSV will do. We used trips_xaa.csv from https://blobs.duckdb.org/data/nyc-taxi-dataset/ (20M rows, 7.95 GB, header added).
duckdb.exe -csv -c "SELECT cab_type, COUNT(*) FROM read_csv_auto('trips.csv') GROUP BY cab_type" > NUL
duckdb.exe -csv -c "SET enable_progress_bar=false; SELECT cab_type, COUNT(*) FROM read_csv_auto('trips.csv') GROUP BY cab_type" > NUL
duckdb.exe -csv -c "SELECT cab_type, COUNT(*) FROM read_csv_auto('trips.csv') GROUP BY cab_type" | findstr /v /c:"__none__" > NULMedian of 3 runs, file already in the OS cache (one warm-up run per engine first), run order rotated each round:
| stdout | v1.5.5 | v2.0.0-alpha43678 |
|---|---|---|
> NUL |
12.99 s | 128.64 s (119.7 / 128.6 / 130.7) |
> NUL, enable_progress_bar=false |
12.71 s | 10.27 s |
pipe (| findstr) |
12.74 s | 10.05 s |
Disabling the progress bar removes the slowdown completely, so it looks like the progress bar is being rendered, or its update is blocking, when stdout is the NUL device. A likely reason is that NUL is a character device, so _isatty() returns true for it on Windows. We haven't verified that.
We saw the same thing earlier with v2.0.0-alpha43650, when a benchmark launched DuckDB from Python with stdout sent to the null device (subprocess.DEVNULL).
Unconfirmed side note: with stdout redirected to a file (> out.csv), the alpha took 21.3 s against 10.1 s piped, while 1.5.5 was 12.8 s either way. We haven't tested that case with the progress bar off, so it may or may not have the same cause.
OS:
GitHub Actions windows-latest (Windows Server 2025, x64, 4 logical CPUs)
DuckDB Version:
v2.0.0-alpha43678
DuckDB Client:
Python
Hardware:
No response
Full Name:
Melih Birim
Affiliation:
NA
Did you include all relevant configuration (e.g., CPU architecture, Linux distribution) to reproduce the issue?
- Yes, I have
Did you include all code required to reproduce the issue?
- Yes, I have
Did you include all relevant data sets for reproducing the issue?
Yes
Source: duckdb/duckdb