Repository navigation
Conversation
The global tag index stores each element's coarse index (a multiple of
0x100), so Query_Statement::execute intersected the constraints' ranges
with whole coarse cells (intersect_ranges) and read every element of each
candidate's cell. In dense areas that is thousands of elements per
candidate: for maxheight ways in a 1 x 1 degree box around Worcester, 2,185
distinct way blocks for 1,025 results.
Each element type's id map (the skeleton file's Random_File) gives exact
indices. exact_indices_pay_off compares the map blocks the candidate ids
fall in (the map holds a fixed number of ids per block and decompresses one
block at a time) with the skeleton blocks the coarse ranges touch
(Block_Backend::count_blocks); when the map blocks are fewer than half,
the ranges are further intersected with the candidates' exact indices
(get_indexes_, exact_ranges). At a past date nothing changes.
On a US northeast full-history extract (Geofabrik), warm cache, 4-core VM,
median CPU of 3 alternating runs:
[out:json][timeout:90]; (way["maxheight"]["highway"](42.0,-72.0,43.0,-71.0); way["bridge"]["maxheight"](42.0,-72.0,43.0,-71.0); way["tunnel"]["maxheight"](42.0,-72.0,43.0,-71.0); node["maxheight"]["highway"](42.0,-72.0,43.0,-71.0); ); out center;
1.24 s -> 0.88 s, way blocks read 3,389 -> 391
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01736kJWpJaGbt8ML6jz9N35
This was referenced Nov 27, 2026
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.
Stacked on #243 (
tags-global-bbox-prune): it changes the range intersection that PR moved. The tables compare against #243's branch.Fixes #246.
Change
exact_indices_pay_off(statements/query.cc) estimates both costs from the block indices alone: the id-map blocks the candidate ids fall in (the map holds a fixed number of ids per block and decompresses one block at a time, so that is about one block per distinct block), against the skeleton blocks the coarse ranges touch (Block_Backend::count_blocks, from query: drop tag-index candidates outside the query's ranges during the lookup #243).get_indexes_,exact_ranges).One file, 50 lines added. No change to the database format, the query API or the results.
Impact
US northeast full-history extract (Geofabrik), warm cache, 4-core VM. Builds alternate, median user+sys CPU of 3 runs. The queries: the 1° × 1° maxheight query from #242 in three boxes (dense, sparse, empty) and their 0.99999° versions, and the 20 heaviest query templates on the public servers in June 2026 moved to Boston and New England coordinates (p01–p20). Base is #243's branch (77135ca).
Way blocks read for dense_1: 3,389 (2,185 distinct) → 391.
Why the cost check. A first version used exact indices whenever there were at most 65,536 candidates. That made three
aroundqueries (p02, p06, p17) 11–32% slower in instructions: their thousands of candidates are spread across the id space, so each map lookup decompressed its own map block. With the check they are now neutral or faster.Queries
dense_1:
sparse_1:
empty_1:
The 0.99999° versions shrink each box's north and east edges by 0.00001°. p01 is dense_1.
p01 (maxheight bbox1deg)
p02 (amenities around union)
p03 (admin in area)
p04 (brands bbox ci)
p05 (global data center)
p06 (food around regex)
p07 (global seamark recurse)
p08 (global cameras)
p09 (3d buildings bbox)
p10 (tourism around25k)
p11 (brownfield bigbbox)
p12 (clinic name ci around25k)
p13 (map call meta)
p14 (area by name worship)
p15 (tiny bbox many keys geom)
p16 (hgv restrictions bbox)
p17 (anchored regex around)
p18 (fuel bigbbox)
p19 (venues bbox name ci)
p20 (office around25k)
Testing
fuzz,historyandpropsstarted by hand (workflow_dispatchwith this branch asref), since those workflows run on pull requests only againstmaster.Limitations and open questions
Generated by Claude Code