Skip to content

SQL pushdown lane: bound the block-size probe instead of a full COUNT(*) #1784

Closed

Description

@bplatz

Once an outer side passes one key set (2000 rows), SqlBlockSource::count_block sends SELECT COUNT(*) over the branch to decide whether to fetch it whole and hash-join in memory (see fluree-db-query/src/r2rml/sql_lane/mod.rs). The count is unbounded: on the 1M-row Postgres shop.orders it costs about 15 ms per query even though the answer (1,000,000) exceeds the cache cap the moment it passes 100,000, and the block stays seeded anyway.

Measured with sql_pushdown_lane_probe (outer-orders-5k): 25 ms seeded without the probe, 43 ms with it.

A bounded probe would cap that cost at the cap itself: SELECT COUNT(*) FROM (<branch statement> LIMIT cap + 1) AS p. That needs a derived-table node in the plan IR (RelNode) and renderer support on each dialect, plus the fake endpoint's parser, which is why it was not done with the cache itself.

Activity

  1. added
    P3
    area:query
    on Sep 3, 2026
  2. added a commit that references this issue on Sep 4, 2026
    7ba9678
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

    P3area:query

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions