Skip to content

fix(sql): enable leading-key pruning for distributed Top-K scans - #32261

Merged
mergify[bot] merged 8 commits into
matrixorigin:mainfrom
ck89119:issue-32219-main
Nov 6, 2026
Merged

mergify[bot] merged 8 commits into
matrixorigin:mainfrom
ck89119:issue-32219-main

Conversation

@ck89119

@ck89119 ck89119 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Related to #32219.

What this PR does / why we need it:

Enable safe leading-key dynamic block pruning for multi-key Top-K scans, including remote execution. Preserve the full Top comparator and equal-leading-key candidates; do not extend single-key static reader limits or hidden-sort-key rewrites to multi-key ordering.

Carry TopValueTag and scan ordering through pipeline serialization. Remote readers own their block permutation and cloned, tightening threshold without mutating shared RelData. Keep unknown boundaries and conservatively fall back for unsupported mappings. Reject JSON and geometry-family leading keys for both single- and multi-key pruning: JSON semantic order differs from byte-ordered zonemaps, and geometry types lack a zonemap comparator. Preserve main's resident/spill Top paths, OrderedOutput, and ordered MergeTop/DOP boundaries. Protobuf bindings were regenerated from main's schema.

Validation on main (Go 1.27.1, Darwin/arm64 CPU):

  • Six owning/direct-consumer packages passed; reader and Top regressions each passed 100 race repetitions, plus the complete readutil package under race.
  • Changed-line coverage: 110/118 (93.22%); vet, incremental lint, formatting, and protobuf reproducibility passed.
  • mo-tester: one- and two-CN configurations each passed two comparisons, 92/92 statements per run, including ties, OFFSET, NULL/name fallbacks, BF16 controls, and JSON/GEOMETRY ordering across separately flushed objects (ASC/DESC, single/multi-key, TP/AP and pruning-disabled controls).
  • Controlled two-key scans read 1/16 blocks on one CN and 4/16 on two-CN AP versus disabled pruning; equal-leading-key controls retained all four blocks and returned the correct secondary-key winners.
  • After merging the latest main, planner focused and complete planner/compile tests with coverage, type-family checks, vet, incremental lint, the service build and one-/two-CN BVT were rerun. Unchanged reader/Top race, codec, generation and integer scan-count evidence were retained after an upstream-input audit.

This is the main-specific adaptation of #32242, not a blind cherry-pick. The original production 30-second timeout was not reproduced; these results do not establish its unique cause or guarantee production latency improvements.

@XuPeng-SH

XuPeng-SH commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: ab8674a87e76b2c9b6d2f7cb33b1ddf57d485d34

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-local · review

Commit: ab8674a87e76b2c9b6d2f7cb33b1ddf57d485d34

Assessment: approve

Leading-key pruning preserves full Top-K comparison and ties while reusing existing feedback mechanisms. Reader-owned ordering isolates shared data. No actionable defects found.

Model: gpt-6.1-sol / max

Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0

Validation:

  • Reviewed all 13 changed paths, relevant owners and consumers, linked issue and complete discussion; source remained unchanged.

  • Protobuf descriptor audit and isolation preflight passed; receipts and terminal logs retained.

  • Frozen CI records 13 successful contexts, including build, unit tests and multi-CN BVT. Author reports focused race tests and controlled pruning comparisons.

Limitations:

  • Local reader test stopped before compilation because libmo.so was missing and native artifact reuse was rejected; no local product-test pass claimed.

  • Raw author validation logs were unavailable; the original production timeout was not reproduced.

@mergify mergify Bot added the queued label Nov 6, 2026
@mergify

mergify Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

✅ Merged into main as 5aa9884 at 11:38 UTC

1 h 7 min in the queue, 1 h 2 min of it CI.

So far

  • ✅ Entered the queue Fri 6 Nov, 10:31 · rule main · triggered by rule Automatic queue on approval for main
  • ✅ Passed · in place
  • ✅ Merged 11:38 · 5aa9884 · squash
3 merge conditions met
  • #review-threads-unresolved = 0 · required by GitHub branch protection
  • github-review-approved · required by GitHub branch protection
  • any of · required by GitHub branch protection:
    • check-success = CI Required
    • check-neutral = CI Required
    • check-skipped = CI Required

Times in UTC · dashboard · how the merge queue works

This branch was previously deployed

1 inactive deployment
ci — 2fe41d68 Deployed Nov 6, 2026 by mergify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants