Skip to content

perf(read): the match_scores page reads are O(active scores) — ~1 s per page at 10⁷; an entity-keyed edge projection would bound them #1440

Done

Description

@athvin

The observation (measured in #833)

Every per-page results read over match_scores is linear in the tenant's active scores, not in the page size. Measured in-process on DuckDB 2.0.1 / DuckLake with rows in write order (the table declares no order_by), 50-row pages:

statement 2M active scores 8M active scores rows read
within_groups (/duplicates, /merge-plans) p50 196 ms p50 761 ms all of them
uncertain_page p50 254 ms p50 784 ms the band (~60%)
active_page p50 245 ms p50 780 ms ~50% (keyset half)

That's about 100 ms per million active scores, so roughly 1 s per page at 10⁷. Live p3live (780k records) serves /duplicates at p50 1227 / p95 1330 ms and /merge-plans at p50 1761 ms per 50-entity page.

What does not work (measured)

  • Bounding scored through the page's members (rec_a_key IN (SELECT record_key FROM members)): no gain at either size. A page's members are scattered across the whole key space, so neither the zone maps nor the join filter prune anything.
  • Sort-on-write by rec_a_key helps active_page only: 245 → 20 ms at 2M and 780 → 23 ms at 8M, measured on a sorted copy. within_groups and uncertain_page stay the same for the same reason. It also needs DuckLake's table-level sort, because upsert_from_scored is a MERGE.

Candidates

  1. An entity-keyed edge projection: write entity_id alongside each within-group edge at reconcile time, sorted by entity_id. within_groups then range-scans by the page's id range, as members already does.
  2. A table-level sort on match_scores (rec_a_key, rec_b_key) for active_page.
  3. A probability-sorted layout (or a band partition) for uncertain_page.

Each needs its own measurement on the same harness before it ships. Done when the three reads are bounded by page size at 10⁷ active scores, or a verdict says why not.

Activity

  1. added
    followup
    on Nov 29, 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

    followup

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions