Skip to content

Down recursion at past dates reads node blocks twice when the input has relations #94

Open

Description

@cldellow

Follow-up to #16 and its fix, #18.

Problem

Down recursion (>) over relations collects the relations' node members and the ways' nodes in two separate passes over the node blocks. #18 merged them into one pass for current data only. At a past date ([date:], or the old side of [diff:]), each pass still reads the current and attic node files, plus the current and attic node metadata that attic queries use to check versions.

Block reads (one LZ4 block each, counted by tracing mmap), Nova Scotia history database, built with #18 applied:

[date:"2018-01-01T00:00:00Z"][out:csv(::count)]; rel[route=hiking]; (._;>;); out count;
File Reads Distinct blocks
nodes.bin 914 460
nodes_attic.bin 638 320

Relation node members are usually few, but they're spread out. The relations' pass alone reads 773 node blocks and 1,640 node metadata blocks for this query, and costs about 0.6 s of 1.7 s.

>> at a past date already reads each node block once. A query with only ways as input (way[highway=primary](44.60,-63.66,44.70,-63.52); (._;>;);) still reads node blocks twice at a date, but that's the bounding-box filter reading way geometry and then > reading the same nodes. That's a separate cost between statements, not this one.

Fix

Use the merged pass (relation_and_way_node_members, which already handles attic objects) for dates too.


Generated by Claude Code

Activity

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