Repository navigation
fix: enable vector index with single-row vector providers - #24394
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? |
aunjgr
left a comment
There was a problem hiding this comment.
Upgrading to approve. On reflection my prior comment overstated the type-aliasing concerns:
- The function binder enforces matching types on dist function args before the rewrite runs, so the
distFnArgs[1].Typ = distFnArgs[0].Typmutation is a no-op in practice. - Width-mismatch rejection happens earlier in the binder.
- The pre-existing non-join
getArgsFromDistFnuses the same pattern and has been in production.
The hardening notes (trivial-OnList strictness, dead Node_SORT branch, UK reasoning comment, IVF range-opt disabled on join path) and the test gaps (OUTER/composite-PK rejection, execution-level correctness) are genuine but non-blocking — please address as follow-ups.
LGTM.
Merge Queue Status
This pull request spent 1 hour 17 seconds in the queue, including 59 minutes 38 seconds running CI. Required conditions to merge
|
…#24394) (#24561) Cherry-pick of #24394 to 4.0-dev. This PR enables a conservative vector index rewrite when the query vector is provided by a single-row derived table in a trivial INNER JOIN. Approved by: @XuPeng-SH, @aunjgr
…in#24394) This PR enables a conservative vector index rewrite when the query vector is provided by a single-row derived table in a trivial INNER JOIN. Changes: - Recognize vector ORDER BY over a join shape where one side is the indexed table and the other side provides the query vector. - Limit the rewrite to trivial INNER JOIN cases where the provider side can be proven to produce at most one row by primary-key or unique-key equality filters. - Require the provider vector to be provably non-NULL before passing it to IVF/HNSW table functions. - Keep the provider subtree as the IVF/HNSW function scan child so the vector argument remains reachable. - Add planner tests for accepted and rejected rewrite cases plus coverage for the new helper branches. Review safety updates: - SINGLE JOIN / scalar subquery shapes are no longer rewritten because the zero-row provider case must preserve NULL-extension semantics. - Bare LIMIT 1 is no longer accepted as a global single-row proof. - Nullable provider vectors fall back to the original plan unless non-NULL can be proven by column metadata or an isnotnull filter. Tests: - go test ./pkg/sql/plan - go test ./pkg/sql/plan -covermode=set -coverprofile=/tmp/issue23158-plan.out - git diff --check - npx -y markdownlint-cli2 CLAUDE_TODO_2026-05-14.md - make - make static-check Approved by: @aunjgr
…in#24394) This PR enables a conservative vector index rewrite when the query vector is provided by a single-row derived table in a trivial INNER JOIN. Changes: - Recognize vector ORDER BY over a join shape where one side is the indexed table and the other side provides the query vector. - Limit the rewrite to trivial INNER JOIN cases where the provider side can be proven to produce at most one row by primary-key or unique-key equality filters. - Require the provider vector to be provably non-NULL before passing it to IVF/HNSW table functions. - Keep the provider subtree as the IVF/HNSW function scan child so the vector argument remains reachable. - Add planner tests for accepted and rejected rewrite cases plus coverage for the new helper branches. Review safety updates: - SINGLE JOIN / scalar subquery shapes are no longer rewritten because the zero-row provider case must preserve NULL-extension semantics. - Bare LIMIT 1 is no longer accepted as a global single-row proof. - Nullable provider vectors fall back to the original plan unless non-NULL can be proven by column metadata or an isnotnull filter. Tests: - go test ./pkg/sql/plan - go test ./pkg/sql/plan -covermode=set -coverprofile=/tmp/issue23158-plan.out - git diff --check - npx -y markdownlint-cli2 CLAUDE_TODO_2026-05-14.md - make - make static-check Approved by: @aunjgr
What type of PR is this?
Which issue(s) this PR fixes:
fixes #23158
What this PR does / why we need it:
This PR enables a conservative vector index rewrite when the query vector is provided by a single-row derived table in a trivial INNER JOIN.
Changes:
Review safety updates:
Tests: