cockroachdb / cockroachdb/cockroach

opt: implement NOT operator in PlanGrams

Open
#172,179 0 comments 0 reactions 0 assignees View on GitHub
A-plan-management A-statement-hint C-enhancement T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

(Breaking this out from https://github.com/cockroachdb/cockroach/issues/152053.)

For statements with many possible plans, it might sometimes be easier to describe the set of pinned plans in terms of which plans are _not_ pinned, rather than which plans are pinned. To support this, we will need to [add a NOT operator to PlanGrams](https://github.com/cockroachdb/cockroach/blob/8ba72f3434ea5547293eb034cebd689000d5f777/pkg/sql/opt/props/physical/plangram.go#L80). This will turn matches into mismatches within the optimizer's PlanGram matching logic.

(Note that this NOT operator would be different from the existing special ["none" term](https://github.com/cockroachdb/cockroach/blob/8ba72f3434ea5547293eb034cebd689000d5f777/pkg/sql/opt/props/physical/plangram.go#L163-L165), which indicates that there are no matches at the current PlanGram production.)

Jira issue: CRDB-65337

Contributor guide

Open the contributing guide

Research direction

Start with pkg/sql/opt/props/physical/plangram.go, especially the PlanGram terms and the existing "none" term, then trace the optimizer's PlanGram matching logic. The work is done when a NOT operator turns matches into mismatches while remaining distinct from "none"; the issue does not name a specific test to run.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.