Skip to content

[Bug] Search: a query-time scan's lower bound takes the shortest possible reader window, so the cheaper plan is never proposed (#987) #994

Open

Description

@GordonYuanyc

Example

scans_projecting_different_labels_are_shared (crates/devtools/tests/stage_pipeline.rs:1821) fails on main. It requires a cost of at most 0.1518.

Commit Selected Cost/s
f06a5556 (before #987) seed-joint-plan-2: a narrow 5 m scan plus a separate wide 15 s scan 0.1507630
249ebd23 (#987) seed-joint-plan-3: one widened 5 m scan 0.2100327

Prices did not change: #987 touches only lower_bounds.rs and the search's rounding tolerance. The search now selects a plan that costs 39% more.

Main's CI did not catch this. CI stopped at the stale planner_fuzz #902 test first, which #992 fixes.

Current behavior

The full search rounds never validate a plan on this workload, before or after #987, even with a 120 s limit. So the seed round decides the result (5 s, 32 evaluations, route.rs:115).

Seed proposals' bounds Seed proposals evaluated, cost/s
Before #987 0 0.1592, then 0.1508
After #987 0.0074 each 0.6547, 0.2110, 0.2100

Cause:

  • shortest_reader_windows (lower_bounds.rs:282) bounds a query-time scan by the shortest window of any reader that might read it.
  • The widened 5 m scan can also be read by the instant selectors, so it is bounded at their 15 s lookback: 0.0074, 20× below its real 0.148.
  • The two-scan plan has a higher bound. Proposals go in bound order, so it is never proposed within the budget.

Expected behavior and invariant

The bound stays sound but depends on the readers actually selected, so the cheaper plan is proposed and the test's 0.1518 holds. One option is a MILP constraint cost_s ≥ price(rows(w_r)) · x(r reads s) for each reader connection, instead of a fixed bound at the shortest possible window. This stays sound because the evaluator reads the longest selected window.

Regression test

The existing test, scans_projecting_different_labels_are_shared.

Related: #963, #987.

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

    bugSomething isn't workingsearchCandidate-plan search space and algorithms

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions