use pk info to reduce redundant group by columns
Open
sig/planner
type/enhancement
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Enhancement
Consider the case that
`select a.pk, a.col1, a.col2, a.col3, count(*) from a join b where a.id = b.id group by a.pk, a.col1, a.col2, a.col3`
TiDB will generate a plan that use `a.pk, a.col1, a.col2, a.col3` as the group by key. In fact since a.pk is pk from table a, the sql can be optimized as
`select a.pk, first_row(a.col1), first_row(a.col2), first_row(a.col3), count(*) from a join b where a.id = b.id group by a.pk`
Contributor guide
Assessment
This issue has not been assessed yet.