Skip to content

query: build the late tag check's ids one cell at a time - #235

Open
cldellow wants to merge 1 commit into
masterfrom
tags-late-ids-per-cell
Open

cldellow wants to merge 1 commit into
masterfrom
tags-late-ids-per-cell

Conversation

@cldellow

@cldellow cldellow commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Fixes #234.

Change

  • Query_Statement::filter_by_tags (the overload with attic items, statements/query.cc) creates one entry per cell in ids_by_coarse without ids. The range query and filter_by_ids still need every cell.
  • fill_cell_ids fills a cell's ids from the items, and from the attic items at a past date, just before filter_ids_by_tags runs for that cell. The list then shrinks to its matches, so the map ends up holding only matching ids.
  • The order is unchanged: cells are visited in ascending order, and items, grouped by cell in their map order, are consumed alongside, as filter_by_ids already does.

One file, 35 lines added, 3 removed. 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 run alternately; peak RSS and median user+sys CPU of 3 runs per query. Run-to-run CPU noise is about ±4% per query. Base is upstream/master a9d8f15.

Query peak, base peak, this PR change CPU, base CPU, this PR change
d1 509 MB 509 MB -0% 16.28 s 15.46 s -5%
d4 220 MB 220 MB +0% 6.91 s 6.87 s -1%
h8 544 MB 544 MB +0% 8.46 s 8.46 s +0%
m1 174 MB 137 MB -21% 1.46 s 1.29 s -12%
p01 13 MB 13 MB +0% 1.56 s 1.62 s +4%
p04 237 MB 238 MB +0% 6.79 s 6.27 s -8%
p09 54 MB 53 MB -0% 3.35 s 3.34 s -0%
p15 23 MB 23 MB +0% 0.54 s 0.54 s +0%
p16 77 MB 77 MB -0% 9.18 s 9.00 s -2%
p19 17 MB 17 MB +0% 7.59 s 7.38 s -3%
CPU total 62.1 s 60.2 s -3.0%

On upstream/master only m1 shows the gain: for d1, h8 and p04 the unchunked candidate collection dominates the peak, which the chunk-cap PRs address. With them (on all-changes plus a 16 MiB cap), this adds −8% on m1 and h8 and −2% on p04 and d4.

Instruction counts (valgrind callgrind; these repeat exactly between runs):

Query base this PR change
s_m1_meta_amenity_small 3.239 G 3.116 G -3.81%
p06 4.433 G 4.404 G -0.65%
Queries m1, d1, d4, h8, s_m1

d1 (adiff amenity buildings)

[adiff:"2025-01-01T00:00:00Z","2026-11-01T00:00:00Z"]; (node["amenity"](42.2,-71.3,42.5,-70.9); way["building"](42.3,-71.15,42.4,-71.0); ); out geom;

d4 (diff convert)

[diff:"2024-01-01T00:00:00Z","2026-11-01T00:00:00Z"]; nwr["amenity"](42.3,-71.2,42.4,-71.0); convert item ::id=id(), name=t["name"], amenity=t["amenity"]; out;

h8 (attic amenity meta)

[date:"2018-06-01T00:00:00Z"]; (node["amenity"](42.2,-71.3,42.5,-70.9); way["amenity"](42.2,-71.3,42.5,-70.9);); out meta;

m1 (meta amenity)

node["amenity"](42.2,-71.3,42.5,-70.9); out meta;

s_m1_meta_amenity_small (m1 meta amenity small)

node["amenity"](42.3,-71.15,42.4,-71.0); out meta;
The 20 queries

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

  • Byte-identical output to upstream/master on all 10 queries above, and on m1, d1, h8, d4, m3 and p04 again after the final cleanup commit.
  • CI: fuzz, history and props run on this PR.

Limitations and open questions

  • The other filter_by_tags overload (without attic items) still builds all ids up front. It handles the remaining element kinds and could get the same treatment.
  • With only negated tag filters ([k!=v], [!k]), no positive filter narrows a cell's list, so the map ends up holding all candidate ids as before: no gain there, and no loss.


Generated by Claude Code

Query_Statement::filter_by_tags checks tags late for candidates collected
by area: generate_ids_by_coarse copied the id of every candidate into a
map of per-cell id lists, and filter_ids_by_tags then narrowed each list
to the matching ids. All candidate ids were held at once, alongside the
candidates themselves, although only one cell's are needed at a time.

filter_by_tags now creates the map's entries (one per cell, still needed
for the range query and filter_by_ids) without ids, and fill_cell_ids
fills a cell's ids from the items, and attic items at a past date, just
before that cell is filtered. Each list then shrinks to its matches, so
the map ends up holding only those.

On a US northeast full-history extract (Geofabrik), warm cache, 4-core VM,
median of 3 alternating runs:

  node["amenity"](42.2,-71.3,42.5,-70.9); out meta;
      peak RSS 174 MB -> 137 MB, CPU 1.46 s -> 1.29 s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01736kJWpJaGbt8ML6jz9N35
@cldellow cldellow added query-memory query-perf Query performance change; collected on all-changes labels Nov 26, 2026 — with Claude
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Late tag checks hold every candidate's id at once

2 participants