Repository navigation
perf: batch PyLovo linking by cell index, not a grid join - #213
Merged
Merged
Conversation
GetGridBatches built an ST_SquareGrid over the envelope of all buildings and joined every building's point to every cell. For one country database holding two regions far apart the envelope is mostly empty: Deggendorf and Koeln, 27,420 buildings, span 438 x 233 km, so 103,400 cells and about 2.8 billion ST_Intersects calls in a nested loop. -link-pylovo spent 29 minutes in this query before linking started. Each building's cell is now floor(x / size), floor(y / size) of a point inside its footprint, and batches are grouped by that index. The cells are the same origin-aligned squares, every building still lands in exactly one batch, and empty cells never exist. On the same database the query returns the same 49 batches in 39 ms.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
-link-pylovospent 29 minutes batching buildings before linking began, on one country database holding Deggendorf and Köln (27,420 buildings). The linking itself took under a second.Cause
GetGridBatchesbuilt anST_SquareGridover the envelope of all buildings and joined every building's point to every cell. The two regions span 438 x 233 km, so 103,400 cells; the planner estimated 1,000 and chose a nested loop: about 2.8 billionST_Intersectscalls.Change
floor(x / size), floor(y / size)of a point inside its footprint, and batches are grouped by that index. The cells are the same origin-aligned squares, every building still lands in exactly one batch, and empty cells are never built.CHANGELOG.md: Fixes entry.Tests
TestGetGridBatches_*integration tests and the rest of./internal/process/pass. No test fails before this change: the output is unchanged and only the cost differs.