cockroachdb / cockroachdb/cockroach
opt: normalize and optimize 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.)
The optimizer uses a simple top-down interpretive walk to match optimizer expressions against PlanGrams. This means that two PlanGrams that describe the same set of plans could have very different matching performance, depending on the construction of the PlanGrams themselves.
There are some simple optimizations we could do to a PlanGram to make it cheaper to match against (which mostly have to do with reducing the number of distinct productions). We should consider doing some or all of these when loading a PlanGram from disk.
1. remove chain rules by computing the transitive closure
2. remove useless or unreachable nonterminals
3. remove / combine duplicate nonterminals
4. inline nonterminals called from one place
(And there are many more ideas from [Tree Automata Techniques and Applications](https://jacquema.gitlabpages.inria.fr/files/tata.pdf) that we could consider.)
Jira issue: CRDB-65338
Contributor guide
Research direction
Start by reading the parent issue 152053 and the PlanGram loading and matching design described here, then review the referenced Tree Automata Techniques and Applications paper. Define which normalization steps to pursue and compare matching performance before and after loading PlanGrams from disk; done means the selected optimizations are implemented and validated without changing the represented plans.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- databases
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100