sql/indexrec: support vector index recommendations
commit 2b53fc6 ↗ · cockroachdb/cockroach · · committed May 5, 2026 · +791−52 · base 542a5b01648a
Agent prompt
what a new run launched now would send
EXPLAIN's index recommendations do not yet cover vector nearest-neighbor queries. For statements that order by a vector distance expression (<->, <=>, or <#>) with a LIMIT (optionally with equality predicates on other columns), the recommender never proposes a vector index, even when a hypothetical vector index would yield a better plan.
Extend the index recommendation engine so that:
1. Vector columns used in those distance operators become index candidates (including eq-prefix + vector combinations, analogous to inverted indexes).
2. Hypothetical vector indexes carry the distance metric implied by the operator so the optimizer can explore vector-search plans.
3. Recommendation SQL uses CREATE VECTOR INDEX with the correct operator class for L2, cosine, and inner product.
4. Recommendations respect existing vector indexes: do not re-recommend an equivalent visible index; do not treat a different distance metric as redundant; invisible indexes are only ALTER … VISIBLE candidates when the metric matches.
5. Operand order must not matter (constant on the left vs variable on the left).
Acceptance is behavioral: EXPLAIN (and the index-recommendation testdata harness) should surface the appropriate creation/alteration recommendations for the cases above across all three metrics.
Work only inside this repository checkout. Make the code change the task
describes, keeping the diff focused — no drive-by refactors.
When you are done, leave your changes committed or in the working tree;
they are collected automatically.
Stay on this snapshot checkout (`task/ycb_cockroach_c2b53fc6a804d`). Never checkout, pull, or rebase onto `main`. That branch is a README-only orphan.
Stay on this HEAD. Do not fetch another default branch. Push only on the Cursor-created `crazy-cursor/…` side branch from this HEAD.
Some past runs of this task were launched with a different prompt (the prompt template changed since, or those runs predate this benchmark's stored prompt). Each run persists the exact prompt it sent at launch — that per-launch record is the audit trail; this page shows only the current one.
Reference diff
The task commit's diff against its first parent — the judge's comparison target.