Skip to content

query: collect few tag-index candidates by their exact indices - #247

Open
cldellow wants to merge 1 commit into
tags-global-bbox-prunefrom
tags-exact-indices
Open

cldellow wants to merge 1 commit into
tags-global-bbox-prunefrom
tags-exact-indices

Conversation

@cldellow

@cldellow cldellow commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

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).
  • When the map blocks are fewer than half the skeleton blocks, the coarse ranges are further intersected with the candidates' exact indices (get_indexes_, exact_ranges).
  • Current date only; past dates are unchanged.

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).

Query CPU, #243 CPU, this PR change
dense_099 6.24 s 6.22 s -0%
dense_1 1.24 s 0.88 s -29%
empty_099 0.00 s 0.00 s —
empty_1 0.00 s 0.00 s —
p01 1.18 s 0.92 s -22%
p02 1.13 s 1.04 s -8%
p03 2.41 s 1.99 s -17%
p04 6.58 s 6.33 s -4%
p05 0.56 s 0.37 s -34%
p06 0.43 s 0.45 s +5%
p07 5.52 s 3.41 s -38%
p08 0.00 s 0.00 s —
p09 3.35 s 3.43 s +2%
p10 4.03 s 3.00 s -26%
p11 3.90 s 2.71 s -31%
p12 0.90 s 0.89 s -1%
p13 0.19 s 0.18 s -5%
p14 0.49 s 0.28 s -43%
p15 0.52 s 0.52 s +0%
p16 6.84 s 5.51 s -19%
p17 0.53 s 0.55 s +4%
p18 10.40 s 6.60 s -37%
p19 6.56 s 3.65 s -44%
p20 0.19 s 0.17 s -11%
sparse_099 0.73 s 0.70 s -4%
sparse_1 0.04 s 0.03 s —
total 64.0 s 49.8 s -22.1%

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 around queries (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:

[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;

sparse_1:

[out:json][timeout:90]; (way["maxheight"]["highway"](41.0,-70.5,42.0,-69.5); way["bridge"]["maxheight"](41.0,-70.5,42.0,-69.5); way["tunnel"]["maxheight"](41.0,-70.5,42.0,-69.5); node["maxheight"]["highway"](41.0,-70.5,42.0,-69.5); ); out center;

empty_1:

[out:json][timeout:90]; (way["maxheight"]["highway"](39.0,-70.0,40.0,-69.0); way["bridge"]["maxheight"](39.0,-70.0,40.0,-69.0); way["tunnel"]["maxheight"](39.0,-70.0,40.0,-69.0); node["maxheight"]["highway"](39.0,-70.0,40.0,-69.0); ); out center;

The 0.99999° versions shrink each box's north and east edges by 0.00001°. p01 is dense_1.

p01 (maxheight bbox1deg)

[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;

p02 (amenities around union)

[out:json][timeout:30]; (node["amenity"="school"](around:3000,42.3601,-71.0589); way["amenity"="school"](around:3000,42.3601,-71.0589); node["amenity"="kindergarten"](around:3000,42.3601,-71.0589); way["amenity"="kindergarten"](around:3000,42.3601,-71.0589); node["amenity"="hospital"](around:5000,42.3601,-71.0589); node["amenity"="clinic"](around:5000,42.3601,-71.0589); way["amenity"="hospital"](around:5000,42.3601,-71.0589); node["amenity"="pharmacy"](around:3000,42.3601,-71.0589); node["shop"~"supermarket|convenience|mall"](around:2000,42.3601,-71.0589); way["shop"~"supermarket|convenience|mall"](around:2000,42.3601,-71.0589); node["highway"="bus_stop"](around:1500,42.3601,-71.0589); node["public_transport"="stop_position"](around:1500,42.3601,-71.0589); node["railway"="station"](around:5000,42.3601,-71.0589); node["railway"="halt"](around:5000,42.3601,-71.0589); way["natural"="water"](around:3000,42.3601,-71.0589); relation["natural"="water"](around:3000,42.3601,-71.0589); way["landuse"="forest"](around:3000,42.3601,-71.0589); relation["landuse"="forest"](around:3000,42.3601,-71.0589); way["leisure"="park"](around:2000,42.3601,-71.0589); way["highway"~"primary|secondary|tertiary"](around:2000,42.3601,-71.0589); way["highway"~"residential|unclassified|service"](around:500,42.3601,-71.0589); way["railway"~"rail|narrow_gauge"](around:1000,42.3601,-71.0589); way["landuse"="industrial"](around:3000,42.3601,-71.0589); node["landuse"="landfill"](around:5000,42.3601,-71.0589); way["landuse"="landfill"](around:5000,42.3601,-71.0589); node["amenity"="post_office"](around:3000,42.3601,-71.0589); node["amenity"="fuel"](around:3000,42.3601,-71.0589); ); out center body;

p03 (admin in area)

[out:json][timeout:30]; area(3600061315)->.country; (way["boundary"="administrative"]["admin_level"="8"](area.country); relation["boundary"="administrative"]["admin_level"="8"](area.country); ); out geom;

p04 (brands bbox ci)

[out:json][timeout:25]; (node["amenity"~"fuel|truck_stop"]["brand"~"travelcenters of america|petro stopping center|love's travel stop|ta travelcenters|pilot flying j|sapp brothers|pilot travel|seven eleven|road ranger|sapp bros|race trac|flying j|ta petro|buc-ee's|racetrac|speedway|circle k|7-eleven|7 eleven|flyingj|buc ees|am best|circlek|7eleven|love's|bucees|ambest|ambest|loves|pilot|petro|7-11|7 11|wawa|ta",i](42.16,-71.26,42.56,-70.86); node["amenity"~"fuel|truck_stop"]["name"~"travelcenters of america|petro stopping center|love's travel stop|ta travelcenters|pilot flying j|sapp brothers|pilot travel|seven eleven|road ranger|sapp bros|race trac|flying j|ta petro|buc-ee's|racetrac|speedway|circle k|7-eleven|7 eleven|flyingj|buc ees|am best|circlek|7eleven|love's|bucees|ambest|ambest|loves|pilot|petro|7-11|7 11|wawa|ta",i](42.16,-71.26,42.56,-70.86); way["amenity"~"fuel|truck_stop"]["brand"~"travelcenters of america|petro stopping center|love's travel stop|ta travelcenters|pilot flying j|sapp brothers|pilot travel|seven eleven|road ranger|sapp bros|race trac|flying j|ta petro|buc-ee's|racetrac|speedway|circle k|7-eleven|7 eleven|flyingj|buc ees|am best|circlek|7eleven|love's|bucees|ambest|ambest|loves|pilot|petro|7-11|7 11|wawa|ta",i](42.16,-71.26,42.56,-70.86); way["amenity"~"fuel|truck_stop"]["name"~"travelcenters of america|petro stopping center|love's travel stop|ta travelcenters|pilot flying j|sapp brothers|pilot travel|seven eleven|road ranger|sapp bros|race trac|flying j|ta petro|buc-ee's|racetrac|speedway|circle k|7-eleven|7 eleven|flyingj|buc ees|am best|circlek|7eleven|love's|bucees|ambest|ambest|loves|pilot|petro|7-11|7 11|wawa|ta",i](42.16,-71.26,42.56,-70.86); node["shop"~"convenience|supermarket"]["brand"~"travelcenters of america|petro stopping center|love's travel stop|ta travelcenters|pilot flying j|sapp brothers|pilot travel|seven eleven|road ranger|sapp bros|race trac|flying j|ta petro|buc-ee's|racetrac|speedway|circle k|7-eleven|7 eleven|flyingj|buc ees|am best|circlek|7eleven|love's|bucees|ambest|ambest|loves|pilot|petro|7-11|7 11|wawa|ta",i](42.16,-71.26,42.56,-70.86); node["shop"~"convenience|supermarket"]["name"~"travelcenters of america|petro stopping center|love's travel stop|ta travelcenters|pilot flying j|sapp brothers|pilot travel|seven eleven|road ranger|sapp bros|race trac|flying j|ta petro|buc-ee's|racetrac|speedway|circle k|7-eleven|7 eleven|flyingj|buc ees|am best|circlek|7eleven|love's|bucees|ambest|ambest|loves|pilot|petro|7-11|7 11|wawa|ta",i](42.16,-71.26,42.56,-70.86); node["leisure"~"fitness_centre|sports_centre"]["brand"~"planet fitness|planet-fitness|crunch fitness|crunch-fitness|planetfitness|crunch gym",i](42.16,-71.26,42.56,-70.86); node["leisure"~"fitness_centre|sports_centre"]["name"~"planet fitness|planet-fitness|crunch fitness|crunch-fitness|planetfitness|crunch gym",i](42.16,-71.26,42.56,-70.86); way["leisure"~"fitness_centre|sports_centre"]["brand"~"planet fitness|planet-fitness|crunch fitness|crunch-fitness|planetfitness|crunch gym",i](42.16,-71.26,42.56,-70.86); way["leisure"~"fitness_centre|sports_centre"]["name"~"planet fitness|planet-fitness|crunch fitness|crunch-fitness|planetfitness|crunch gym",i](42.16,-71.26,42.56,-70.86); node["amenity"="gym"]["brand"~"planet fitness|planet-fitness|crunch fitness|crunch-fitness|planetfitness|crunch gym",i](42.16,-71.26,42.56,-70.86); node["amenity"="gym"]["name"~"planet fitness|planet-fitness|crunch fitness|crunch-fitness|planetfitness|crunch gym",i](42.16,-71.26,42.56,-70.86); way["amenity"="gym"]["name"~"planet fitness|planet-fitness|crunch fitness|crunch-fitness|planetfitness|crunch gym",i](42.16,-71.26,42.56,-70.86); ); out center tags;

p05 (global data center)

[out:json][timeout:300]; (node["telecom"="data_center"]; way["telecom"="data_center"]; ); out center tags;

p06 (food around regex)

[out:json][timeout:40]; (node["amenity"~"restaurant|cafe|ramen|sushi|izakaya|fast_food|bar|pub|food_court"](around:500,42.3601,-71.0589); way["amenity"~"restaurant|cafe|ramen|sushi|izakaya|fast_food|bar|pub|food_court"](around:500,42.3601,-71.0589); node["amenity"~"school|university|college|kindergarten"](around:1000,42.3601,-71.0589); way["amenity"~"school|university|college|kindergarten"](around:1000,42.3601,-71.0589); node["amenity"~"hospital|clinic|doctors|pharmacy"](around:5000,42.3601,-71.0589); way["amenity"~"hospital|clinic|doctors|pharmacy"](around:5000,42.3601,-71.0589); node["railway"~"station|halt"](around:1000,42.3601,-71.0589); way["railway"~"station|halt"](around:1000,42.3601,-71.0589); node["highway"="bus_stop"](around:1000,42.3601,-71.0589); node["amenity"="parking"](around:500,42.3601,-71.0589); way["amenity"="parking"](around:500,42.3601,-71.0589); node["shop"="convenience"](around:500,42.3601,-71.0589); way["shop"="convenience"](around:500,42.3601,-71.0589); node["tourism"~"hotel|motel|hostel|guest_house|ryokan"](around:2000,42.3601,-71.0589); way["tourism"~"hotel|motel|hostel|guest_house|ryokan"](around:2000,42.3601,-71.0589); ); out center;

p07 (global seamark recurse)

(rel['seamark:type']; >; way['seamark:type']; >; node['seamark:type']; ); out meta;

p08 (global cameras)

[out:json][timeout:30]; (node["camera:type"="traffic_monitoring"]["camera:url"]; node["camera:type"="traffic_monitoring"]["camera:image"]; node["camera:type"="traffic_monitoring"]["image"]; node["camera:type"="traffic_monitoring"]["url"]; node["surveillance:type"="traffic_monitoring"]["camera:url"]; node["surveillance:type"="traffic_monitoring"]["camera:image"]; node["surveillance:type"="traffic_monitoring"]["image"]; node["surveillance:type"="traffic_monitoring"]["url"]; node["man_made"="surveillance"]["camera:type"="traffic_monitoring"]["camera:url"]; node["man_made"="surveillance"]["camera:type"="traffic_monitoring"]["camera:image"]; node["man_made"="surveillance"]["camera:type"="traffic_monitoring"]["image"]; node["man_made"="surveillance"]["camera:type"="traffic_monitoring"]["url"]; ); out body;

p09 (3d buildings bbox)

[out:json][timeout:360][bbox:42.34,-71.08,42.38,-71.04]; (nwr["building"]; nwr["building:part"]; relation["type"="building"]; nwr["highway"]; nwr["landuse"]["landuse"!="salt_pond"]; nwr["natural"]["natural"!="coastline"]["natural"!="bay"]["natural"!="strait"]; nwr["leisure"]; nwr["water"]["water"!="bay"]["water"!="ocean"]["water"!="sea"]["tidal"!="yes"]; nwr["waterway"]["waterway"!="tidal_channel"]; nwr["amenity"]; nwr["tourism"]; nwr["bridge"]; nwr["railway"]; nwr["roller_coaster"]; nwr["barrier"]; nwr["entrance"]; nwr["door"]; nwr["power"]; nwr["historic"]; nwr["emergency"]; nwr["advertising"]; nwr["man_made"]; nwr["aeroway"]; nwr["3dmr"]; way["place"]["place"!~"^(ocean|sea|bay|strait|sound|fjord)$"]; way; )->.relsinbbox; (way(r.relsinbbox); )->.waysinbbox; (node(w.waysinbbox); node(w.relsinbbox); )->.nodesinbbox; .relsinbbox out body; .waysinbbox out body; .nodesinbbox out skel qt;

p10 (tourism around25k)

[out:json][timeout:45]; (node["tourism"](around:25000,42.3601,-71.0589); way["tourism"](around:25000,42.3601,-71.0589); node["amenity"~"restaurant|cafe|bar|pub|nightclub|fast_food|food_court|biergarten|ice_cream|bakery"](around:25000,42.3601,-71.0589); way["amenity"~"restaurant|cafe|bar|pub"](around:25000,42.3601,-71.0589); node["amenity"~"theatre|cinema|museum|arts_centre|library|community_centre|concert_hall|studio"](around:25000,42.3601,-71.0589); way["amenity"~"theatre|cinema|museum|arts_centre"](around:25000,42.3601,-71.0589); node["leisure"~"park|garden|stadium|sports_centre|swimming_pool|beach_resort|water_park|marina|golf_course"](around:25000,42.3601,-71.0589); way["leisure"~"park|garden|stadium|nature_reserve"](around:25000,42.3601,-71.0589); node["shop"~"mall|department_store|supermarket|marketplace|clothes|books|gift|art|antiques|wine|craft|boutique"](around:25000,42.3601,-71.0589); way["shop"~"mall|department_store|marketplace"](around:25000,42.3601,-71.0589); node["historic"](around:25000,42.3601,-71.0589); way["historic"](around:25000,42.3601,-71.0589); node["natural"~"peak|beach|spring|cave_entrance|volcano|waterfall"](around:25000,42.3601,-71.0589); node["man_made"~"tower|lighthouse|windmill"](around:25000,42.3601,-71.0589); ); out body center 500;

p11 (brownfield bigbbox)

[out:json][timeout:180]; (way["landuse"="brownfield"](40.5,-80.0,47.5,-67.0); way["landuse"="landfill"](40.5,-80.0,47.5,-67.0); node["man_made"="dump"](40.5,-80.0,47.5,-67.0); way["abandoned:landuse"="industrial"](40.5,-80.0,47.5,-67.0); ); out geom;

p12 (clinic name ci around25k)

[out:json][timeout:30]; (node["amenity"="clinic"]["name"~"cosmetic|aesthetic|beauty|skin|plastic",i](around:25000,42.3601,-71.0589); way["amenity"="clinic"]["name"~"cosmetic|aesthetic|beauty|skin|plastic",i](around:25000,42.3601,-71.0589); node["healthcare"~"aesthetics|cosmetics",i](around:25000,42.3601,-71.0589); way["healthcare"~"aesthetics|cosmetics",i](around:25000,42.3601,-71.0589); ); out body center qt;

p13 (map call meta)

[bbox:42.355,-71.065,42.365,-71.055]; (node(42.355,-71.065,42.365,-71.055); way(bn); node(w); ); (._; (rel(bn)->.a; rel(bw)->.a; ); rel(br); ); out meta;

p14 (area by name worship)

[out:json][timeout:90]; area["name"="Massachusetts"]->.searchArea; (node["amenity"="place_of_worship"]["religion"="jewish"](area.searchArea); way["amenity"="place_of_worship"]["religion"="jewish"](area.searchArea); rel["amenity"="place_of_worship"]["religion"="jewish"](area.searchArea); ); out body 200;

p15 (tiny bbox many keys geom)

[out:json][timeout:25][bbox:42.3580,-71.0620,42.3624,-71.0565]; (node[amenity]; way[amenity]; relation[amenity]; node[building~"^(commercial|retail|office|public|civic|school|college|university|kindergarten|hospital|clinic|transportation|train_station|church|chapel|mosque|temple|synagogue|hotel|supermarket)$"]; way[building~"^(commercial|retail|office|public|civic|school|college|university|kindergarten|hospital|clinic|transportation|train_station|church|chapel|mosque|temple|synagogue|hotel|supermarket)$"]; relation[building~"^(commercial|retail|office|public|civic|school|college|university|kindergarten|hospital|clinic|transportation|train_station|church|chapel|mosque|temple|synagogue|hotel|supermarket)$"]; node[entrance]; node[highway~"^(bus_stop|crossing|elevator)$"]; way[highway~"^(bridleway|bus_guideway|cycleway|footway|living_street|motorway|motorway_link|path|pedestrian|primary|primary_link|residential|residential_link|road|secondary|secondary_link|service|steps|tertiary|tertiary_link|trunk|trunk_link|unclassified)$"]; relation[highway~"^(bridleway|bus_guideway|cycleway|footway|living_street|motorway|motorway_link|path|pedestrian|primary|primary_link|residential|residential_link|road|secondary|secondary_link|service|steps|tertiary|tertiary_link|trunk|trunk_link|unclassified)$"]; node[historic]; way[historic]; relation[historic]; node[indoormark="beacon"]; way[indoormark="beacon"]; relation[indoormark="beacon"]; way[landuse="construction"]; relation[landuse="construction"]; node[leisure]; way[leisure~"^(pitch|park|garden|playground|sports_centre|stadium|golf_course|marina|water_park)$"]; relation[leisure~"^(pitch|park|garden|playground|sports_centre|stadium|golf_course|marina|water_park)$"]; node[office]; way[office]; relation[office]; node[railway~"^(platform|station|subway_entrance|tram_stop)$"]; way[railway~"^(platform|station)$"]; relation[railway~"^(platform|station)$"]; node[shop]; way[shop]; relation[shop]; node[tourism]; way[tourism]; relation[tourism]; way[zoo="enclosure"]; relation[zoo="enclosure"]; ); out geom;

p16 (hgv restrictions bbox)

[out:json][timeout:120]; (way["maxheight"](41.2400,-73.5100,42.8900,-69.9300); way["maxweight"](41.2400,-73.5100,42.8900,-69.9300); way["maxlength"](41.2400,-73.5100,42.8900,-69.9300); way["maxwidth"](41.2400,-73.5100,42.8900,-69.9300); way["hazmat"](41.2400,-73.5100,42.8900,-69.9300); way["hgv"](41.2400,-73.5100,42.8900,-69.9300); node["maxheight"](41.2400,-73.5100,42.8900,-69.9300); node["maxweight"](41.2400,-73.5100,42.8900,-69.9300); ); out geom;

p17 (anchored regex around)

[out:json][timeout:15]; (node["amenity"~"^(restaurant|fast_food|cafe|pharmacy|school|food_court)$"](around:4828,42.3601,-71.0589); way["amenity"~"^(restaurant|fast_food|cafe|pharmacy|school|food_court)$"](around:4828,42.3601,-71.0589); node["shop"~"^(supermarket|grocery|convenience|bakery)$"](around:4828,42.3601,-71.0589); way["shop"~"^(supermarket|grocery|convenience|bakery)$"](around:4828,42.3601,-71.0589); node["leisure"~"^(park|recreation_ground|fitness_centre|fitness_center|dog_park|playground)$"](around:4828,42.3601,-71.0589); way["leisure"~"^(park|recreation_ground|fitness_centre|fitness_center|dog_park|playground)$"](around:4828,42.3601,-71.0589); relation["leisure"~"^(park|recreation_ground)$"](around:4828,42.3601,-71.0589); ); out center tags;

p18 (fuel bigbbox)

[out:json][timeout:420]; (node["amenity"="fuel"](40.5,-80.0,46.6,-69.7); way["amenity"="fuel"](40.5,-80.0,46.6,-69.7); ); out center;

p19 (venues bbox name ci)

[out:json][timeout:90]; (node["amenity"~"community_centre|arts_centre|theatre|cinema|concert_hall|events_venue|convention_centre|conference_centre|social_facility|public_building"](41.80,-72.00,43.05,-70.10); node["leisure"~"sports_hall|sports_centre|ice_rink|arena"](41.80,-72.00,43.05,-70.10); node["building"~"gymnasium|sports_hall|civic|hall|public|community_centre|grandstand|sports_centre"](41.80,-72.00,43.05,-70.10); node["amenity"="gym"](41.80,-72.00,43.05,-70.10); node["name"~"town hall|community center|community centre|recreation center|civic center|function hall|grange hall|vfw post|american legion|masonic|banquet|convention center|fairgrounds|exhibition center",i](41.80,-72.00,43.05,-70.10); way["amenity"~"community_centre|arts_centre|theatre|cinema|concert_hall|events_venue|convention_centre|conference_centre|social_facility|public_building"](41.80,-72.00,43.05,-70.10); way["leisure"~"sports_hall|sports_centre|ice_rink|arena"](41.80,-72.00,43.05,-70.10); way["building"~"gymnasium|sports_hall|civic|hall|public|community_centre|grandstand|sports_centre"](41.80,-72.00,43.05,-70.10); way["name"~"town hall|community center|community centre|recreation center|civic center|function hall|grange hall|vfw post|american legion|masonic|banquet|convention center|fairgrounds|exhibition center",i](41.80,-72.00,43.05,-70.10); relation["amenity"~"community_centre|arts_centre|theatre|cinema|concert_hall|events_venue|convention_centre|conference_centre|social_facility|public_building"](41.80,-72.00,43.05,-70.10); relation["leisure"~"sports_hall|sports_centre|ice_rink|arena"](41.80,-72.00,43.05,-70.10); relation["building"~"gymnasium|sports_hall|civic|hall|public|community_centre|grandstand|sports_centre"](41.80,-72.00,43.05,-70.10); ); out center tags;

p20 (office around25k)

[out:json][timeout:30]; (node["office"="hr"](around:25000,42.3601,-71.0589); way["office"="hr"](around:25000,42.3601,-71.0589); node["office"="consulting"]["name"~"hr|human resource|talent|workforce|people",i](around:25000,42.3601,-71.0589); way["office"="consulting"]["name"~"hr|human resource|talent|workforce|people",i](around:25000,42.3601,-71.0589); ); out body center qt;

Testing

Limitations and open questions

  • The factor of two in the cost check is a judgment, not a measured optimum.
  • The id-map lookups are not cached between statements: a union of statements over the same candidates looks them up once per statement.


Generated by Claude Code

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

query-perf Query performance change; collected on all-changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants