Replies: 2 comments 1 reply
-
I tried the same Does this mean duckdb always loads the fully result set in memory instead of streaming the result? |
Beta Was this translation helpful? Give feedback.
-
There are functions in the C API to use a streaming approach instead of materialising the entire result set. In the CLI, we likely don't use them (their C++ equivalents), and the same for go-duckdb. I wouldn't mind switching to a streaming approach, but I expect it to require a bit of work on how to best use the (partially) deprecated functionality in the C API. Maybe including some PRs to duckdb/duckdb reworking bits of it. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I am trying to limit the number of rows a query can return without modifying the SQL code.
It seems as simple as calling
rows.Close()
after a certain amount of rows.But it seems like internally either DuckDB or the driver is loading the whole result set into memory.
I am running the following example script:
The code behaves correctly for small datasets.
But my dataset has 50 million rows and my terminal simply crashes with an OOM error.
Interestingly it doesn't OOM if I only select a single column.
It feels like there must be a way to safeguard against this happening without adding
LIMIT
to the SQL. I am not even sure what part of the system is loading all the data into memory.Do you have any ideas what I am doing wrong? Thank you.
Beta Was this translation helpful? Give feedback.
All reactions