-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Suboptimal query plan on grouped aggregation with LIMIT and ORDER BY #93410
Copy link
Copy link
Closed
Copy link
Labels
C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-sql-queriesSQL Queries TeamSQL Queries Team
Description
Describe the problem
In support issue https://github.com/cockroachlabs/support/issues/1949, a hash group-by + TopK plan is chosen over a streaming group-by when there is a LIMIT on the query because of unique constraints on certain columns, causing the number of grouping columns to be reduced by the optimizer. When one of the unique indexes is dropped, the fast query plan is picked.
To Reproduce
Use the statement bundles in the support issue.
Jira issue: CRDB-22320
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-sql-queriesSQL Queries TeamSQL Queries Team
Type
Projects
Status
Done