refactor(duckdb): use .sql
instead of .execute
in performance-senitive locations
#8669
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In #6875 we switched to using
con.sql(sql)
instead ofcon.execute(sql)
when retrieving an arrow table of results. The former is more efficient than the latter since the.sql
api lets the query planner take advantage of the known output type, possibly resulting in a more efficient execution.In the
the-epic-split
refactor this optimization was dropped (note - it seems less necessary since duckdb 0.9.0, although they say a performance difference is still expected). We add the optimization back here, and apply it to all locations where we return in-memory data.We choose not to use
duckdb_con.sql
instead ofduckdb_con.execute
in the public-facingraw_sql
api, since:dbapi
APIcon.sql
returnsNone
Fixes #8631.