cockroachdb / cockroachdb/cockroach
opt: incorrect costing of some streaming set ops
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
There are two cases where the optimizer will plan streaming set operators:
1. When the required ordering of the set op can be provided by both inputs (I think).
2. When the inputs provide matching interesting orderings.
In the case of (2), the `SetPrivate.Ordering` field is populated with the streaming ordering. In (1) it is not. We use the `SetPrivate.Ordering` to determine if a set op is streaming or not:
https://github.com/cockroachdb/cockroach/blob/17d0e21c4dba69e2f483f35ddbca8d012c59773c/pkg/sql/opt/xform/coster.go#L1388-L1394
So in the case of (1) we are incorrectly costing it as a non-streaming set op.
I also find it very confusing that for (1) there is no indication in the formatted optimizer expression that the set op is streaming. And in (2), the only indication is the `internal-ordering` field. I think that should be made very obvious in both cases, if possible.
Jira issue: CRDB-50439
Contributor guide
Assessment
This issue has not been assessed yet.