Skip to content

opt: add PlanGramMismatchPenalty cost penalty flag#169717

Open
michae2 wants to merge 2 commits intocockroachdb:masterfrom
michae2:plangram-mismatch-penalty
Open

opt: add PlanGramMismatchPenalty cost penalty flag#169717
michae2 wants to merge 2 commits intocockroachdb:masterfrom
michae2:plangram-mismatch-penalty

Conversation

@michae2
Copy link
Copy Markdown
Collaborator

@michae2 michae2 commented May 5, 2026

Add a new PlanGramMismatchPenalty to the cost penalty bitmask. This penalty will be applied when a plan does not match the required PlanGram pattern. Its precedence is stronger than UnboundedCardinalityPenalty but weaker than FullScanPenalty, so that inline hints (which set FullScanPenalty or HugeCostPenalty) take precedence over PlanGram matching.

Informs: #152053

Release note: None

Co-Authored-By: roachdev-claude [email protected]

@trunk-io
Copy link
Copy Markdown
Contributor

trunk-io Bot commented May 5, 2026

Merging to master in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@michae2 michae2 requested review from a team, DrewKimball and ZhouXing19 May 5, 2026 15:52
@michae2 michae2 marked this pull request as ready for review May 5, 2026 15:52
@michae2
Copy link
Copy Markdown
Collaborator Author

michae2 commented May 5, 2026

First commit is #169197 and can be ignored.

michae2 and others added 2 commits May 5, 2026 22:20
Implement ParsePlanGram, a recursive-descent parser with 1-token
lookahead for plangram grammars. The parser reads from an io.Reader
using bufio.Scanner with a custom SplitFunc.

A reverse-lookup function OperatorByCamelCase is added to the optgen
code generator to map camel-case operator names (e.g. "InnerJoin") back
to opt.Operator values during parsing.

Informs: cockroachdb#152053

Release note: None

Co-Authored-By: roachdev-claude <[email protected]>
Add a new PlanGramMismatchPenalty to the cost penalty bitmask. This
penalty will be applied when a plan does not match the required PlanGram
pattern. Its precedence is stronger than UnboundedCardinalityPenalty but
weaker than FullScanPenalty, so that inline hints (which set
FullScanPenalty or HugeCostPenalty) take precedence over PlanGram
matching.

Informs: cockroachdb#152053

Release note: None

Co-Authored-By: roachdev-claude <[email protected]>
@michae2 michae2 force-pushed the plangram-mismatch-penalty branch from 9154815 to 1760f15 Compare May 6, 2026 05:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants