cockroachdb / cockroachdb/cockroach
opt: add With expressions to tail-call logic
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
We analyze the body of a routine in `memo.ExtractTailCalls` to determine when it is possible to apply tail-call optimization to its execution. Now that CTEs are supported within routines, we should add support for them to this function. A routine call embedded within the (main) input expression of a `WithExpr` is a valid tail call, provided it satisfies the other conditions within `ExtractTailCalls`.
Jira issue: CRDB-46960
Contributor guide
Research direction
Start with memo.ExtractTailCalls and trace its existing tail-call conditions, then inspect how a WithExpr exposes its main input expression. The work is complete when a routine call in that input is recognized as a valid tail call while the existing conditions remain enforced.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, sql
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100