Repository navigation
perf(plan): bound covered FULLTEXT2 score searches - #30193
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: ff01c7b7f7801f92688c87f01f6bb47afc066f76
Assessment: approve
Reviewed the complete seven-file delta and affected planner/search consumers. The design appropriately reuses CandidateLimit and the existing search implementation, requiring exact qualification and equivalent score ordering while preserving outer pagination and fallback paths. No actionable correctness, ownership, compatibility, or test-quality defects remain.
Model: gpt-6-astra / xhigh
Session: 01a12d8f-7dea-77c2-a565-38d45b5564e4 · slot 0 · generation 0
Validation:
-
Preflight passed. Independently reconciled 192 native inputs and 62 retained build artifacts against build-owner provenance. Source remained unchanged.
-
30 focused planner, FULLTEXT2, and search-consumer tests passed with -count=1 and -vet=all. Receipt: checks/1792003658941490387-3.json; log: focused-check.log.
-
Five additional planner boundary cases passed, covering implicit/hidden scores and rejection of residual predicates and DISTINCT. The same run's frontend probe stopped because its diagnostic fixture omitted the experimental feature flag; that failure remains recorded.
-
After correcting only the diagnostic setup, the frontend SQL probe passed filtering-before-top-K, LIMIT/OFFSET, zero limits, prepared-statement reuse, BM25/TF-IDF comparisons, and cleanup. Receipt: checks/1792003954136442345-5.json; log: frontend-boundary-check.log.
-
Formatting, diff checks, source fingerprints, commands, exit receipts, and logs reconciled successfully. Audit receipt: checks/1792004102942419298-3.json. Detailed evidence is retained in /home/xupeng/.local/state/mo-bot/jobs/81607ae4e152e674277bfde9/attempt-1/validation-summary.json and review-analysis.json.
-
Frozen current-head CI metadata reports successful required CI, Ubuntu UT, Linux/arm64 SCA, pessimistic multi-CN BVT, and proxy BVT.
Limitations:
-
Raw external CI artifacts and historical experiment logs were not independently reconciled. The linked issue's full text was absent; review covered the stated follow-up contract and unchanged residual path.
-
No fresh base/head performance benchmark was run. Expected gains come from reduced result materialization and transport; large K and many segments can increase retained memory relative to streaming. Current-head latency and concurrent throughput remain unmeasured.
-
Documented historical B/C coverage measurements report p50 594.386 versus 195.277 ms and p95 1318.612 versus 769.484 ms. These are explicitly scoped to an older version and do not isolate this planner change.
Merge Queue Status
This pull request spent 2 hours 51 minutes 23 seconds in the queue, with no time running CI. ReasonPull request #30193 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
HintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Waiting for any of
All conditions
Tick the box to put this pull request back in the merge queue (same as
|
…t test matrixorigin#30193 added this call after matrixorigin#30189 added the orderOverwritten parameter, so pkg/sql/plan tests do not compile on main. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ore-limit test" This reverts commit 3896399. The fix belongs to main (matrixorigin#30189 x matrixorigin#30193), not to this PR. Co-Authored-By: Claude Opus 5.5 <[email protected]>
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue #30164 Integration follow-up to #30189 and #30193, based on main `8795f3699b` after the emergency revert #30285. References the optional-inner-sort repair in #30274; that reference PR is unchanged. ## What this PR does / why we need it: Restore removal of implicit fulltext relevance sorts when an explicit order replaces them, while preserving safe covered FULLTEXT2 score candidate limits. The revert restored compilation and Top-K behavior but also restored the redundant sort reported in #30164. The score-LIMIT consumer now accepts both `SORT -> PROJECT -> INDEX_SEARCH_SCAN` and the equivalent shape with an intervening implicit score sort. A present inner sort must still have the same single score-DESC key. Direct-column projection, exact-search, filter, pagination, rank, secondary-key, ASC and overflow barriers remain enforced. The outer sort retains SQL pagination; the search receives LIMIT+OFFSET (2 for LIMIT 2, 3 with OFFSET 1). Search-level rank is also explicitly rejected. Python UDF handlers are conservatively treated as order-sensitive: the wrapper registry flags cannot establish handler purity. This applies recursively inside scalar wrappers and preserves the implicit relevance order before their projections. Update all covered-rewrite test callers together with the ordering change. Public parse/bind/optimize regressions cover default implicit relevance order, explicit MATCH and score aliases, nested pages, LIMIT/OFFSET and unsafe controls. Typed tests independently cover the optional sort's equivalence and refusal barriers. Restore #30189's ordering regressions and extend the canonical candidate-limit BVT with distinct-score pages and combined candidate-bound/single-sort assertions. Validation on `3d263e5c79bef731a1667c8c294708818d932cf6` (local run content matches this commit): - Reproduced raw `461bc8e349` planner UT compilation failure at the missing boolean argument. On an amended baseline containing only that mechanical argument fix, `score_alias` and `score_alias_offset` fail their candidate-limit assertions. - A new public planning regression fails in all 6 direct/wrapped Python UDF scenarios on the previous PR head `25a66777d2`, and passes with the local purity-proof repair. - PASS: fresh native `make -j8 cgo`; focused regressions; complete `pkg/sql/plan` tests (`-count=1`); owning build and vet; incremental golangci-lint. - PASS (reused unchanged consumer evidence): focused FULLTEXT2 search/Top-K/candidate/INCLUDE tests, complete `pkg/fulltext2/plugin/search`, and complete `pkg/sql/colexec/vectorscan` tests. - PASS: default SIMD `mo-service` build and real SQL on a private macOS/arm64 instance, Go 1.27.1. Toolchain PATH was pinned after the system launcher's automatic switching failed. - PASS: normal mo-tester `-n -g -o` comparison of `fulltext2/fulltext2_candidate_limit.sql`, `fulltext2/fulltext2_covered.sql`, and `fulltext/fulltext_overwritten_order.sql`, twice on the same instance: **180/180 statements per round, zero ignored or abnormal**. Fixtures were staged byte-for-byte outside `.codex` to avoid mo-tester's dotted-path rewriting. - PASS: independent test-database residue checks after each round; graceful instance shutdown, closed test ports and removal of its data directory; Python UDF catalog entries are also removed. - Python handler execution: NOT_RUN. The new SQL regression uses real CREATE FUNCTION/EXPLAIN without a Python service to assert the ordering barrier; it does not claim external-handler runtime validation. - Pending: exact-head Linux CI and formal QA/performance acceptance. These functional checks do not claim a throughput improvement. QA required: yes — the full issue's performance acceptance and exact-head CI remain separate from local functional validation. Ready for review; #30164 remains open for QA/performance acceptance. Exact-head CI is still in progress. No scoring, defaults, index format, cache, remote benchmark or issue-lifecycle changes. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Preserve source native collation admission tests and regenerated parser and pipeline artifacts. Reserve upstream DECIMAL MORPC v113 and retain the merged JSON/ODKU/functional-key/binary contracts at v114-v118. Correct the PR-side binary error assertion to require protocol version 118: the receiver is 117, but the error reports the required floor 118. incidental upstream repair, identical to upstream main newer fix at pkg/sql/plan/apply_indices_fulltext_snapshot_test.go:182 (matrixorigin#30193/matrixorigin#30189 cross-integration break). Pass orderOverwritten=false because this explicit-sort fixture has no ancestor ordering override. Only that call line differs from the pinned upstream snapshot test. Validation: planner/frontend build with -p 2; planner Collation tests; exact covered-fulltext score-limit and binary sender/receiver tests pass. Affected collation/pre-insert and merged protocol checks also pass. PR-owned whitespace checks pass.
Base: b24d1b3, including the cross-integration repairs for matrixorigin#30189/matrixorigin#30193 delivered by matrixorigin#30289. Preserve both the ODKU row-alias changes and upstream binder/index-key semantics. Regenerate mysql_sql.go from the merged mysql_sql.y using the repository goyacc flow. Two formatted generations are byte-identical with zero shift/reduce or reduce/reduce conflicts. The generated body matches those bytes; keep the repository's canonical generated command header. Discard the earlier integration against main@461bc8e349. The new base naturally supplies the repaired fulltext production helper and complete snapshot test suite. Both files match the new upstream blobs byte-for-byte; no incidental upstream patch or old test expectation is carried forward. Validation: | Check | Result | | --- | --- | | go build -p 2 ./pkg/sql/plan/... ./pkg/sql/parsers/... | PASS | | Focused planner Insert/ODKU/RowAlias/Alias/PrimaryKeyIdentity and CoveredFulltext/FulltextSnapshot/Snapshot tests; -p 2 -count=1 -timeout=20m | PASS | | TestCoveredFulltext2ScoreLimitOnBoundSQL and every subtest | PASS | | Focused MySQL parser insert/row-alias/keyword/conflict tests; -p 2 -count=1 -timeout=20m | PASS | | Goyacc repeated byte comparison, upstream blob equality, gofmt, git diff --check | PASS | Required CI on this new head will be checked in the next root round. The old-head Ubuntu UT failure and CR ledger remain root-owned.
What type of PR is this?
Which issue(s) this PR fixes:
issue #27251 (related follow-up): extend candidate-bound optimization to fully covered,
score-ordered FULLTEXT2 queries. This does not reopen or broaden the exact
residual pure-MUST membership contract of that issue.
Experiment and harness: https://github.com/matrixorigin/mo-nightly-regression/pull/1730
What this PR does / why we need it:
A covered FULLTEXT2 query with exact INCLUDE qualification and
ORDER BY MATCH(...) DESC LIMIT Kcurrently removes the base-table Join butleaves the internal search unbounded. This PR passes LIMIT+OFFSET through the
existing
IndexSearchScan.CandidateLimitinterface when the search's score orderand every qualification predicate are compatible with early TopK.
The outer SQL sort/pagination remain. Other ordering expressions, ascending
order, secondary tie-break keys, residual filters, rank options, FOUND_ROWS,
and unsupported/overflowing pagination receive no new bound. The original
SHOULD/IS NULL semantics and existing fallback paths remain unchanged.
This is a main-based port of experimental optimization
7447e4bdto the currentINDEX_SEARCH_SCAN representation. It excludes diagnostic-only commit
90af16daand all TKE/runner/cache-policy/default-index changes.
Validation
Original port/local-validation head:
8bab314cd93d7f34ca7bc571bb8ecdea752e9775;prepared base:
fab7b5c0430a475bf64ad1619ce4d5249013a138.Current PR head after merging main:
ff01c7b7f7801f92688c87f01f6bb47afc066f76.The optimization files are unchanged from the locally validated port.
fab7b5c0430a475bf64ad1619ce4d5249013a138: the publicscore-alias SQL regression FAILS because CandidateLimit is nil. The same
SQL shape in the candidate's typed-plan suite carries the expected bound.
alias, LIMIT+OFFSET, ascending/other/expression/secondary order rejection,
explicit null placement, no LIMIT, overflow and SQL_CALC_FOUND_ROWS.
pkg/sql/plan,pkg/fulltext2, and affected search consumerpkg/fulltext2/plugin/searchpackage tests with-count=1 -vet=all: PASS onmacOS arm64 / Go 1.27.1, using the repository CGo wrapper and native build.
git diff --check: PASS.test/distributed/cases/fulltext2/fulltext2_covered.sql/.result.Its three-row oracle requires the eligible lower-scoring document to survive
LIMIT 1 while the highest-scoring document fails exact IS NULL qualification.
Exact-head CI run 38554099046
executed this file in pessimistic multi-CN BVT: 40/40 passed, 0 skipped
(execution artifact 11891768136). Pessimistic and proxy BVT, Linux/arm64 SCA,
and Ubuntu UT coverage passed. Ordinary Ubuntu UT is still in progress;
full CI completion remains a merge gate.
Historical experiment evidence (version-scoped)
The committed evidence record is
docs/performance/anli-ft2-covered-score-topk.md.It retains versions, artifact IDs, data/parameter hashes, protocol and limits.
original MO 7447e4b, A/B/C four-table correctness, DML, rebuild, restart and
content equality PASS under FT2_ASYNC_900_V1. Old strict60/180 failures remain.
observation-only MO 90af16d, one C Q1, complete query identity and oracle PASS;
effective/runtime K=200, exact IS NULL evaluation, SearchInto/no Emit fallback,
and no post-limit residual qualification observed.
same diagnostic MO with collection disabled, 715679 rows per arm, fixed
100-query pack, hot-cache single-client serial timing. Five groups each BC/CB,
20 warmups and 100 timed requests per arm; all ten pairs valid, 2000 timed
samples, no SQL errors or TP restarts. B/C index coverage is the experimental
variable; this is not an old/new planner-version benchmark.
Median of per-pair median request ratios B/C: 2.627073; range 2.542170–2.789526.
These results belong to the frozen historical MO/data/query protocol, not this
ported head, classic FULLTEXT, full two-stage nqft, or concurrent throughput.
The shared workload inventory was stable, but the environment was not exclusive.
Source and independent owner both completed SUCCESS; exact Kubernetes/COS cleanup
and independent local absence checks passed. CBS was explicitly waived/unverified.
Scope and QA
QA required: yes — this is a planner/search TopK correctness boundary. Public
entrypoint: a covered FULLTEXT2 MATCH with exact INCLUDE qualification and score
descending LIMIT/OFFSET. Automation asserts the typed bound and qualification
before truncation. Remaining gates: full exact-head CI completion, reviewer
acceptance, and required QA. Exact-head BVT execution is now verified.
No immediate read-your-writes or cache-freshness fix is claimed. Historical
strict60/180 failures remain failures. No complete A/B/C × Q0–Q3 performance
matrix, index maintenance-cost claim, production rollout, or ANLI baseline
publication is included. Ready for review at the author's request; this is not
merge approval or production-release acceptance.