ENH: improve performance of read_dataframe if a filter is used #577
+126
−44
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
read_dataframe
without arrow, the number of rows of the result was counted first, and then the full data was read.Especially when using a filter, counting the rows can take significant time.
This PR avoids doing the rowcount before reading to improve performance, with these results with the new zealand building outlines geopackage (3.3 million rows) as test file:
where="ST_NPOINTS(st_buffer(geom, 10)) > 2000"
(returning 9 rows) took 82 s, now 45 s.