cockroachdb / cockroachdb/cockroach
opt: implement NOT operator in PlanGrams
- 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
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