Skip to content

Collecting objects at a past date copies two block buffers per index #116

Done

Description

@cldellow

Problem

Queries at a past date ([date:], and the old side of [diff:]) collect objects through collect_items_by_timestamp in data/collect_items.h. For each index, it calls reconstruct_items twice, once for the current file and once for the attic file, and passes the end iterators by value.

A block iterator (Block_Backend_Basic_Iterator) owns a copy of the current block, and its copy constructor copies that whole buffer with memcpy. So every index costs two full buffer copies, whether or not anything there matches. Scans that walk many indexes therefore spend much of their time copying. Examples are member lookups (relation_node_members, way geometry) and the bbox filter on relations at a past date.

Profile of the query below on the all-changes branch (#12), Nova Scotia full-history database (see #2), warm cache: 33% of samples are in memcpy called from the block iterator's copy constructor, under collect_items_range for member nodes and ways.

[date:"2018-01-01T00:00:00Z"][out:xml]; rel(42,-67.6,47.5,-58); out body;

Fix

Pass the end iterators to reconstruct_items by const reference. The comparison operator is already const, and nothing else changes.


Generated by Claude Code

Activity

  1. added
    query-perf
    on Nov 22, 2026
  2. cldellow commented on Nov 23, 2026

    @cldellow
    OwnerAuthor

    Offered upstream in fossgis#8

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-perfupstreamed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions