Skip to content

bbox filter reads the geometry of ways that lie entirely inside the box #19

Open

Description

@cldellow

Problem

A bbox filter on ways reads the nodes of every candidate way to test whether the way really meets the box (Bbox_Filter::filter builds a Way_Geometry_Store for all of into.ways). Most candidates of a typical box lie well inside it, so for them the test can't fail. Their node blocks are read and decompressed only to confirm that.

Evidence

Nova Scotia test database (see #2):

[out:csv(::count)]; nwr[amenity](44.60,-63.66,44.70,-63.52); out count;

In this query (the search part of benchmark query q08), Bbox_Filter::filter accounts for 10.6% of CPU samples, 8.5% of them in Way_Geometry_Store reading node blocks. For a plain way(44.60,-63.66,44.70,-63.52); out count;, the geometry test is about half of the CPU time (see the fix).

Why it can be skipped

A way whose index is a single tile (bit 31 of the Uint31_Index clear) has all its nodes in that tile. If the tile lies inside the box, every node of the way is inside the box. Bbox_Filter::matches accepts any way with a node inside the box: single nodes via contains(), segments via intersects().

🤖 Generated with Claude Code

https://claude.ai/code/session_01736kJUqyDw9zM3Bkh2W2QT


Generated by Claude Code

Activity

  1. cldellow commented on Nov 21, 2026

    @cldellow
    OwnerAuthor

    Caveat found: the shortcut assumes a way's nodes exist

    The history benchmark query h3 (see #2) returns 162 more objects with the fix in #21 than with the baseline (15,078 against 14,916) on the history test database:

    [out:csv(::count)]; nwr(newer:"2026-11-18T00:00:00Z")(43.3,-66.5,47.1,-59.6); out count;
    

    All 162 are ways none of whose nodes exist in that database. The baseline can't build their geometry and excludes them; the shortcut keeps them because their index tile lies inside the box. The index was computed when each way was written, from nodes that were deleted later. The test database has these broken references because of gaps in its regional filtering of planet diffs.

    OpenStreetMap's API refuses to delete a node that a way still uses, so planet-derived databases shouldn't contain such ways, and there the shortcut's output is identical. Next step: rebuild the history database from a complete full-history extract and re-check.

    🤖 Generated with Claude Code

    https://claude.ai/code/session_01736kJUqyDw9zM3Bkh2W2QT


    Generated by Claude Code

  2. added
    query-perf
    on Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    query-perf

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions