Skip to content
Discussion options

You must be logged in to vote

The reader, which is returned by all the result methods with "read" in the name, is designed to do what you describe: fetch chunks and store them as you go. If you'd like to fetch chunks and discard them as you go, you should avoid the reader, and use the lower-level methods that fetch one chunk at a time, such as result.fetchChunk(). To ensure DuckDB doesn't fully materialize the result in memory, use connection.stream() instead of connection.run() to run the SQL and get the result object.

To make this even easier, the async iterator pattern is implemented on the result object. So, you can fetch one chunk at a time (without storing them) using an async loop like:

for await (const chunk of 

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jraymakers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #337 on November 12, 2025 05:20.