Repository navigation
fix(spatial): keep joins on term ids within the query memory (#811) - #821
Conversation
The side estimated smaller is held in at most half of the query memory and the other is read in parts of a quarter of it, each part swept against the held side and its pairs added to the table. When the held side, a part and the table would pass the limit, the query fails with the memory error, as a hash join of the evaluator does. Without a limit nothing changes.
|
Changes requested at 50f25cd. The design (hold the smaller side in half the limit, stream the other in quarters, fail past the limit) fits #811 and the accounting reads right. Two must-fix items, both small. 1. With no query memory set, a side past the 1 GiB guard is no longer read in parts (regression of #340). 2. The memory error is read from the shared Small, with the same push: the doc comment of Not blocking, for the next scale run as the issue says: at the default 1 GiB a join whose smaller side passes 512 MiB now answers 503 where it answered before; from the 1B diagnostic run the Generated by Claude Code |
…the right query (#811) Without a query memory, join_ids_each_part takes usize::MAX values as parts within the join memory again, as join_ids_in_parts did, rather than one part of the whole side. The memory error is decided from the query's own rewrite statistics, not the engine's last ones, which a concurrent query may replace.
|
Approved at 2158f89. Both items are fixed: with no query memory the parts are #340's again (and Generated by Claude Code |
Requested by Mathias · project thread
Closes #811
What and why
A spatial join on term ids held both sides' rows and boxes, and its table, whole, whatever
--query-memorysaid. A join of two large sides could therefore take many times the limit.Now, with a query memory set:
Snapshot::join_ids_each_part, the per-chunk form of perf(spatial): osm_track_landuse times out on OSM Europe at 1B triples #340'sjoin_ids_in_parts). Each part is swept against the held parts, and its pairs are appended to one table.RewriteStats::over_memory. The query then fails withQueryEvaluationError::MemoryLimit, which is 503 on the server, the same as a hash join of the evaluator.tripletrail_spatial::GEOMETRY_BYTES, so the reader's estimate matches the join's accounting. The floor of 64 key values per part is now 1.Documented margin: while a part is read, the values of its key (8 bytes each), plus the parsed geometries of the candidates being tested.
With no limit (
memory_limit()isNone), the sides are read whole as before.How it was tested
joins_on_ids_stay_within_the_query_memoryincost_model.rs, on 2,500 spots and 2,500 zones:a_join_side_larger_than_the_query_memory_is_read_in_parts(perf(spatial): osm_track_landuse times out on OSM Europe at 1B triples #340) still completes at 8 KiB, now in more than one sweep.cargo test -p tripletrail -p tripletrail-spatial -p tripletrail-store, clippy-D warningsand fmt are clean.Documentation
docs/server.md(Query memory): the held, part and table bounds, and the margin.docs/spatial-index.mddocs/guide/13-production.mdGenerated by Claude Code