Repository navigation
Conversation
Around_Constraint chose prefer_ranges whenever the radius was under 2 km. The query statement then reads every object in around's index ranges and checks tag filters afterwards. A small radius around a large input set, such as long relations, still covers a large area, so a selective tag filter went unused. Like Bbox_Constraint, also look at the area: with more than 65536 node index tiles (about one square degree), return ids_useful so that the tag index selects candidates within the ranges. The filters are the same, so results are unchanged. Nova Scotia extract: rel(45.566265,-62.428420,45.586924,-62.388716)->.s0; node(around.s0:0)["footway"]; takes 2.24 s -> 0.08 s. The 9 relations in .s0 include a long trail and boundaries, so their extent covers much of the province. With radius 2000 the same query already took 0.42 s on master, because radius alone decided the strategy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01736kJUqyDw9zM3Bkh2W2QT
This was referenced Nov 21, 2026
Owner
Author
|
Colin's thoughts: low risk, high confidence, low-medium benefit. This is about picking a better query strategy, following prior art in |
This was referenced Nov 21, 2026
Owner
Author
|
Adding needs-followup as I think it'd be interesting to try to improve the common tags case. Common tags are common, so could probably just be hardcoded in (vs doing something smart like regular dumps from osmtaginfo) |
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.
Fixes #9.
Change
Around_Constraint::delivers_data(statements/around.cc) chose the query strategy from the radius alone:prefer_rangesfor any radius under 2 km.With
prefer_ranges, thequerystatement reads every object inaround's index ranges and applies tag filters afterwards. A small radius around a large input set, such as long relations, still covers a large area, so a selective tag filter went unused.This keeps the radius rule and also looks at the area. When
around's node index ranges cover more than 65,536 tiles (about one square degree), it returnsids_useful, so the tag index selects candidates within the ranges.Bbox_Constraintalready applies the same rule (prefer ranges only under 1 square degree). The same filters apply either way, so results are unchanged.One file, about 20 lines. Based on fossgis
master. No change to the database format or the query API.Impact
Wall time (single-threaded, so close to CPU time), Nova Scotia test database (Geofabrik extract of 2026-11-08, imported with
--meta), warm cache, 4-core VM. Outputs are identical.The prompting query (differential fuzzer seed 2, query 425, reduced):
.s0and radius 0master["footway"](the prompting query)["building"]["natural"]["highway"]["highway"="crossing"]["source"](very common)The remaining cost for common tags is geometry testing, which #10 addresses. On
master, the same footway query with radius 2000 already took 0.42 s, because the radius alone flipped the strategy.aroundqueries over small areas keepprefer_rangesand are unchanged, for example benchmark q06 andway(around:250,44.679085,-63.511161)->.s0; way(around.s0:100);.Benchmark queries: all 11 have identical output. Times are within noise (−1% to −8%, total 2,474 → 2,380 ms;
masterfrom the cached baseline, so not alternating). None of them has a large-extentaround, so no real change is expected.Benchmark queries (from
bench/queries/on thebench-toolsbranch)[out:csv(::count)]; nwr[amenity=restaurant]; out count;[out:csv(::count)]; node[natural=peak]; out count;[out:csv(::count)]; node(44.60,-63.66,44.70,-63.52); out count;[out:csv(::count)]; way[highway](44.60,-63.66,44.70,-63.52); out count;[out:csv(::count)]; way[highway=motorway]; (._;>;); out count;[out:csv(::count)]; node[amenity=cafe](44.60,-63.66,44.70,-63.52); node(around:300)[shop]; out count;[out:csv(::count)]; rel[boundary=administrative][admin_level=4][name="Nova Scotia"]; (._;>>;); out count;[out:xml]; nwr[amenity](44.60,-63.66,44.70,-63.52); out meta;[out:json]; way[building](44.640,-63.585,44.655,-63.565); out geom;[out:json]; way[highway](44.60,-63.66,44.70,-63.52); out geom;[out:csv(::count)]; node[highway=traffic_signals](44.60,-63.66,44.70,-63.52); way(bn); rel(bw); out count;Bounding boxes are in Halifax, Nova Scotia; q07 names the Nova Scotia province boundary.
Testing
master(bench/fuzz.py, see Benchmark queries and differential fuzzer #2). 0 differences, 12 skipped (all time out onmaster). Only 18 of these queries take the new path, which a temporary probe build confirmed.rel(<small box around a random sampled node>)->.s0; node|way(around.s0:R)["k"="v"]; out ids;, with R in {0, 50, 500, 1999} and rare or moderately common tags from the fuzzer vocabulary. 82 took the new path, with 0 differences. 2 time out on both builds; they areway(around…)against long power lines, a geometry cost.complete). That covered 10,000 queries across the plain, area and history databases (6,000 / 2,000 / 2,000), with 0 differences. The per-PR fuzz run above predates a fuzzer fix: about 8% of its queries were invalid on both builds, so it rests on roughly 5,500 queries that ran (see Benchmark queries and differential fuzzer #2).Memory
No new allocations beyond computing
around's ranges once more during planning.get_rangesalready recomputes them on each call.Limitations
Bbox_Constraint's 1 square degree; the best cut-off may differ.[date:]/[diff:]queries and areas aren't covered, because the test database has no history and no areas.Generated by Claude Code