Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

planner should support 3 stage aggregation for single scalar distinct agg #37202

Closed
fixdb opened this issue Aug 18, 2022 · 0 comments · Fixed by #37203
Closed

planner should support 3 stage aggregation for single scalar distinct agg #37202

fixdb opened this issue Aug 18, 2022 · 0 comments · Fixed by #37203
Labels
type/enhancement The issue or PR belongs to an enhancement.

Comments

@fixdb
Copy link
Contributor

fixdb commented Aug 18, 2022

Enhancement

Currently, count(distinct) in MPP mode still execute in a single worker, which is bad when there are large number of distinct values. e.g.:

mysql> explain select count(distinct L_ORDERKEY) from lineitem;
+------------------------------------+----------+--------------+----------------+-----------------------------------------------------------+
| id                                 | estRows  | task         | access object  | operator info                                             |
+------------------------------------+----------+--------------+----------------+-----------------------------------------------------------+
| TableReader_18                     | 1.00     | root         |                | data:ExchangeSender_17                                    |
| └─ExchangeSender_17                | 1.00     | mpp[tiflash] |                | ExchangeType: PassThrough                                 |
|   └─Projection_13                  | 1.00     | mpp[tiflash] |                | Column#18                                                 |
|     └─HashAgg_14                   | 1.00     | mpp[tiflash] |                | funcs:count(distinct test.lineitem.l_orderkey)->Column#18 |
|       └─ExchangeReceiver_16        | 1.00     | mpp[tiflash] |                |                                                           |
|         └─ExchangeSender_15        | 1.00     | mpp[tiflash] |                | ExchangeType: PassThrough                                 |
|           └─HashAgg_6              | 1.00     | mpp[tiflash] |                | group by:test.lineitem.l_orderkey,                        |
|             └─TableFullScan_12     | 10000.00 | mpp[tiflash] | table:lineitem | keep order:false, stats:pseudo                            |
+------------------------------------+----------+--------------+----------------+-----------------------------------------------------------+
8 rows in set (0.01 sec)

We should be able to generate a plan with 3 stage aggregation for scalar distinct agg.
NB. only for cases where there is only 1 distinct agg function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant