Skip to content

Conversation

@englefly
Copy link
Contributor

@englefly englefly commented Jan 8, 2025

What problem does this PR solve?

after extracting common expressions for agg, the underlying projection may project redundant columns.
for example:
original plan
Agg(groupkey=[A+B, A+B+1])
--> project(A, B)

after extracting, "A+B as C" is detected as a common expression, and the plan becomes
Agg(groupKey=[C, C+1])
-->project(A, B, A+B as C)

here A, B should not be projected, since they are not used any more. so the optimal plan is
Agg(groupKey=[C, C+1])
-->project(A+B as C)

Related PR: #40473

Problem Summary:

Release note

None

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

@hello-stephen
Copy link
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@englefly
Copy link
Contributor Author

englefly commented Jan 8, 2025

run buildall

@doris-robot
Copy link

TPC-H: Total hot run time: 30745 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 231c07a736d04ce4755dd5c4263d166021f37842, data reload: false

------ Round 1 ----------------------------------
supplier	Doris	NULL	NULL	0	0	0	NULL	NULL	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:27:25	NULL	utf-8	NULL	NULL	
============================================
q1	q2	863	174	162	162
q3	9637	4089	4168	4089
q4	6792	2827	2557	2557
q5	9478	2301	1966	1966
q6	409	163	135	135
q7	928	691	594	594
q8	q9	12748	4914	4920	4914
q10	2884	2267	1830	1830
q11	410	277	262	262
q12	320	370	221	221
q13	17675	3662	2998	2998
q14	247	237	217	217
q15	517	446	463	446
q16	650	629	583	583
q17	557	855	331	331
q18	6875	6467	6434	6434
q19	1241	996	533	533
q20	313	324	181	181
q21	2787	2178	1977	1977
q22	362	334	315	315
Total cold run time: 75693 ms
Total hot run time: 30745 ms

----- Round 2, with runtime_filter_mode=off -----
supplier	Doris	NULL	NULL	1000000	87	87519212	NULL	NULL	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:27:25	NULL	utf-8	NULL	NULL	
============================================
q1	q2	240	334	243	243
q3	2222	2618	2264	2264
q4	1448	1754	1325	1325
q5	4301	4732	4579	4579
q6	171	166	126	126
q7	1960	1812	1729	1729
q8	q9	7106	6911	6872	6872
q10	2903	3072	2675	2675
q11	572	523	484	484
q12	641	742	598	598
q13	3388	3643	3155	3155
q14	298	320	297	297
q15	500	466	445	445
q16	640	689	633	633
q17	1246	1814	1231	1231
q18	7434	7086	6998	6998
q19	809	1142	1026	1026
q20	1941	1942	1759	1759
q21	5456	5075	4910	4910
q22	581	560	568	560
Total cold run time: 43857 ms
Total hot run time: 41909 ms

Copy link
Contributor

@morrySnow morrySnow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add test case please~

@englefly
Copy link
Contributor Author

englefly commented Jan 8, 2025

run buildall

@doris-robot
Copy link

TPC-H: Total hot run time: 28707 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 231c07a736d04ce4755dd5c4263d166021f37842, data reload: false

------ Round 1 ----------------------------------
supplier	Doris	NULL	NULL	0	0	0	NULL	NULL	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:27:25	NULL	utf-8	NULL	NULL	
============================================
q1	q2	2076	182	171	171
q3	17409	4146	4230	4146
q4	11446	797	496	496
q5	13774	2185	1942	1942
q6	432	159	134	134
q7	886	749	605	605
q8	q9	18421	4892	4874	4874
q10	6786	2274	1870	1870
q11	490	280	258	258
q12	343	391	232	232
q13	18097	3707	2985	2985
q14	245	236	205	205
q15	502	461	446	446
q16	670	635	582	582
q17	569	851	328	328
q18	6854	6447	6543	6447
q19	1235	962	543	543
q20	348	317	198	198
q21	2999	2155	1941	1941
q22	360	335	304	304
Total cold run time: 103942 ms
Total hot run time: 28707 ms

----- Round 2, with runtime_filter_mode=off -----
supplier	Doris	NULL	NULL	1000000	87	87519212	NULL	NULL	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:27:25	NULL	utf-8	NULL	NULL	
============================================
q1	q2	242	331	241	241
q3	2283	2655	2281	2281
q4	1415	1784	1386	1386
q5	4291	4763	4617	4617
q6	158	160	125	125
q7	1978	1803	1705	1705
q8	q9	6974	6865	7043	6865
q10	3097	3137	2749	2749
q11	563	511	488	488
q12	658	712	588	588
q13	3388	3665	3164	3164
q14	272	301	263	263
q15	490	445	441	441
q16	652	653	627	627
q17	1183	1707	1220	1220
q18	7281	7151	7076	7076
q19	825	1055	1069	1055
q20	1972	1957	1841	1841
q21	5421	4928	4891	4891
q22	641	591	566	566
Total cold run time: 43784 ms
Total hot run time: 42189 ms

@englefly
Copy link
Contributor Author

englefly commented Jan 9, 2025

run buildall

@doris-robot
Copy link

TPC-H: Total hot run time: 26186 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 8fc5aabbd5f96536a9ee61e4521793ce1d2f7b3f, data reload: false

------ Round 1 ----------------------------------
============================================
q1	q2	2055	174	173	173
q3	17294	882	661	661
q4	10474	887	434	434
q5	12858	2185	1977	1977
q6	434	166	135	135
q7	901	729	616	616
q8	9456	1362	1115	1115
q9	7566	4826	4851	4826
q10	6745	2255	1804	1804
q11	470	264	249	249
q12	339	356	216	216
q13	17755	3654	3101	3101
q14	231	223	204	204
q15	507	446	433	433
q16	648	597	561	561
q17	554	853	324	324
q18	6989	6342	6530	6342
q19	2857	1010	547	547
q20	595	319	185	185
q21	2759	2138	1966	1966
q22	361	332	317	317
Total cold run time: 101848 ms
Total hot run time: 26186 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	q2	390	318	230	230
q3	2260	2656	2237	2237
q4	1434	1773	1404	1404
q5	4338	4764	4591	4591
q6	162	156	125	125
q7	1940	1850	1712	1712
q8	2512	2699	2612	2612
q9	6932	6910	7025	6910
q10	2866	3137	2637	2637
q11	570	512	482	482
q12	636	715	609	609
q13	3260	3666	3092	3092
q14	290	296	266	266
q15	479	448	445	445
q16	645	673	628	628
q17	1178	1683	1214	1214
q18	7315	7211	7056	7056
q19	797	891	1132	891
q20	1912	2005	1883	1883
q21	5418	4972	4810	4810
q22	636	611	589	589
Total cold run time: 45970 ms
Total hot run time: 44423 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 182387 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 8fc5aabbd5f96536a9ee61e4521793ce1d2f7b3f, data reload: false

store_sales	Doris	NULL	NULL	0	0	0	NULL	NULL	NULL	NULL	2023-12-26 22:43:59	2023-12-26 22:59:20	NULL	utf-8	NULL	NULL	
time_dim	Doris	NULL	NULL	0	0	0	NULL	NULL	NULL	NULL	2023-12-26 22:43:59	2023-12-26 22:44:03	NULL	utf-8	NULL	NULL	
warehouse	Doris	NULL	NULL	0	0	0	NULL	NULL	NULL	NULL	2023-12-26 22:43:56	2023-12-26 22:44:01	NULL	utf-8	NULL	NULL	
web_page	Doris	NULL	NULL	0	0	0	NULL	NULL	NULL	NULL	2023-12-26 22:43:59	2023-12-26 22:44:01	NULL	utf-8	NULL	NULL	
web_returns	Doris	NULL	NULL	0	0	0	NULL	NULL	NULL	NULL	2023-12-26 22:43:58	2023-12-26 22:45:43	NULL	utf-8	NULL	NULL	
web_sales	Doris	NULL	NULL	0	0	0	NULL	NULL	NULL	NULL	2023-12-26 22:43:58	2023-12-26 22:53:25	NULL	utf-8	NULL	NULL	
web_site	Doris	NULL	NULL	0	0	0	NULL	NULL	NULL	NULL	2023-12-26 22:43:58	2023-12-26 22:44:01	NULL	utf-8	NULL	NULL	
============================================
query1	971	384	368	368
query2	6513	2312	2391	2312
query3	6707	215	212	212
query4	33326	23233	23301	23233
query5	4806	610	450	450
query6	314	183	174	174
query7	query8	289	242	234	234
query9	10262	2572	2557	2557
query10	572	306	248	248
query11	18388	15092	14911	14911
query12	164	106	111	106
query13	query14	11190	7027	7458	7027
query15	251	203	182	182
query16	8770	602	465	465
query17	1894	748	579	579
query18	2140	438	304	304
query19	221	179	156	156
query20	150	107	109	107
query21	208	119	100	100
query22	4224	4192	4224	4192
query23	34420	33464	33044	33044
query24	6912	2199	2278	2199
query25	492	464	385	385
query26	query27	1716	457	335	335
query28	query29	759	521	414	414
query30	244	186	147	147
query31	989	849	762	762
query32	93	60	60	60
query33	715	350	290	290
query34	1127	765	497	497
query35	816	824	737	737
query36	1007	1023	940	940
query37	120	97	77	77
query38	4085	4393	3996	3996
query39	1463	1437	1413	1413
query40	204	113	98	98
query41	52	48	51	48
query42	119	106	101	101
query43	510	533	476	476
query44	1471	815	796	796
query45	172	174	165	165
query46	1319	1017	649	649
query47	1805	1833	1771	1771
query48	398	418	332	332
query49	789	470	387	387
query50	642	642	384	384
query51	6923	6769	6867	6769
query52	100	102	91	91
query53	217	256	178	178
query54	475	472	404	404
query55	84	82	85	82
query56	266	272	237	237
query57	1167	1107	1066	1066
query58	243	239	231	231
query59	2956	3022	2955	2955
query60	297	268	251	251
query61	118	106	109	106
query62	782	713	638	638
query63	229	192	184	184
query64	query65	3213	3124	3176	3124
query66	query67	15954	15463	15343	15343
query68	4083	730	531	531
query69	457	296	261	261
query70	1208	1100	1135	1100
query71	524	279	256	256
query72	6530	3877	3876	3876
query73	685	763	359	359
query74	9279	9049	8669	8669
query75	3569	3164	2706	2706
query76	3355	1186	744	744
query77	554	366	298	298
query78	10153	9993	9398	9398
query79	3028	786	596	596
query80	query81	560	270	241	241
query82	741	158	122	122
query83	307	164	148	148
query84	248	95	70	70
query85	query86	476	317	281	281
query87	4610	4370	4258	4258
query88	3816	2175	2143	2143
query89	399	317	295	295
query90	2241	192	190	190
query91	170	134	104	104
query92	77	59	53	53
query93	3335	825	531	531
query94	963	384	294	294
query95	343	260	266	260
query96	489	618	273	273
query97	2864	2911	2804	2804
query98	240	203	202	202
query99	1263	1397	1245	1245
Total cold run time: 273390 ms
Total hot run time: 182387 ms

@englefly
Copy link
Contributor Author

englefly commented Jan 9, 2025

run buildall

Comment on lines +961 to +965
Expr result = ExpressionTranslator.translate(e, context);
if (result == null) {
throw new RuntimeException("translate " + e + " failed");
}
return result;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we get more info about translate failed and print them in log?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this message is logged by NereidsPlanner

.flatMap(expr -> expr.getInputSlots().stream())
.collect(Collectors.toSet());
for (NamedExpression expr : project.getProjects()) {
if (!(expr instanceof SlotReference) || newInputSlots.contains(expr)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why need !(expr instanceof SlotReference)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it is not slot, it is alias. if it is alias, it must be used by Aggregate in 2 cases:

  1. directly used by Agg after rewrite
  2. used by inferred common expression.
    In both cases, alias should not be pruned.

@doris-robot
Copy link

TPC-H: Total hot run time: 31992 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 1ecf72ff8cd205eec59f4374a8182c1e981cb594, data reload: false

------ Round 1 ----------------------------------
q1	17681	5614	5445	5445
q2	2047	312	167	167
q3	10408	1228	760	760
q4	10207	881	448	448
q5	7625	2184	2017	2017
q6	193	163	133	133
q7	896	771	614	614
q8	9232	1373	1167	1167
q9	5184	4897	4880	4880
q10	6759	2270	1815	1815
q11	488	280	254	254
q12	344	363	220	220
q13	17789	3722	3075	3075
q14	229	234	205	205
q15	507	484	440	440
q16	638	592	587	587
q17	594	873	329	329
q18	6910	6443	6384	6384
q19	2256	1033	583	583
q20	315	316	192	192
q21	3063	2186	1970	1970
q22	363	345	307	307
Total cold run time: 103728 ms
Total hot run time: 31992 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5627	5513	5521	5513
q2	242	324	230	230
q3	2299	2697	2326	2326
q4	1385	1825	1348	1348
q5	4409	4731	4705	4705
q6	174	159	125	125
q7	2096	1964	1820	1820
q8	2657	2850	2766	2766
q9	7376	7197	7252	7197
q10	3034	3279	2790	2790
q11	591	524	490	490
q12	631	720	572	572
q13	3501	3867	3233	3233
q14	287	303	291	291
q15	507	448	447	447
q16	656	685	645	645
q17	1253	1742	1255	1255
q18	7720	7418	7313	7313
q19	870	1233	1107	1107
q20	2026	2098	1880	1880
q21	5716	5325	4906	4906
q22	620	637	580	580
Total cold run time: 53677 ms
Total hot run time: 51539 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 193426 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 1ecf72ff8cd205eec59f4374a8182c1e981cb594, data reload: false

query1	1294	974	924	924
query2	6326	2342	2262	2262
query3	10987	4624	4688	4624
query4	32574	23380	23313	23313
query5	4361	593	465	465
query6	281	195	196	195
query7	4001	494	300	300
query8	312	233	223	223
query9	9457	2595	2589	2589
query10	474	310	249	249
query11	17892	15223	14969	14969
query12	157	109	105	105
query13	1594	547	428	428
query14	9660	6472	6537	6472
query15	252	220	188	188
query16	8152	621	466	466
query17	1506	754	607	607
query18	2136	432	333	333
query19	211	199	172	172
query20	123	123	116	116
query21	205	129	103	103
query22	4629	4464	4316	4316
query23	34000	33647	33082	33082
query24	6431	2437	2306	2306
query25	530	517	404	404
query26	724	281	156	156
query27	2151	496	340	340
query28	5497	2517	2492	2492
query29	666	561	420	420
query30	211	191	156	156
query31	968	882	835	835
query32	77	57	56	56
query33	506	363	294	294
query34	768	862	530	530
query35	821	852	761	761
query36	1012	1024	958	958
query37	120	104	77	77
query38	4077	4193	4139	4139
query39	1516	1451	1512	1451
query40	211	111	97	97
query41	49	45	49	45
query42	132	107	110	107
query43	532	541	506	506
query44	1364	843	854	843
query45	185	179	164	164
query46	901	1077	661	661
query47	1883	1926	1881	1881
query48	403	409	323	323
query49	713	475	397	397
query50	683	671	390	390
query51	6936	7094	6889	6889
query52	107	102	90	90
query53	234	252	190	190
query54	503	504	432	432
query55	87	82	78	78
query56	256	259	250	250
query57	1193	1178	1154	1154
query58	242	258	242	242
query59	3142	3415	3039	3039
query60	283	270	264	264
query61	115	109	109	109
query62	792	723	655	655
query63	241	194	196	194
query64	3545	1023	649	649
query65	3395	3199	3203	3199
query66	990	406	309	309
query67	16334	15665	15467	15467
query68	8996	719	530	530
query69	477	297	250	250
query70	1202	1049	1146	1049
query71	433	287	250	250
query72	6512	3809	3902	3809
query73	654	743	363	363
query74	10176	9067	8751	8751
query75	3982	3145	2646	2646
query76	3630	1169	758	758
query77	758	365	293	293
query78	9911	10021	9332	9332
query79	3203	826	609	609
query80	568	530	445	445
query81	481	279	223	223
query82	625	147	124	124
query83	166	226	142	142
query84	249	100	84	84
query85	778	365	310	310
query86	352	302	301	301
query87	4468	4332	4202	4202
query88	4508	2233	2200	2200
query89	471	325	295	295
query90	1841	185	201	185
query91	133	137	115	115
query92	64	55	52	52
query93	1590	891	546	546
query94	657	380	278	278
query95	334	260	248	248
query96	491	608	285	285
query97	2848	2947	2765	2765
query98	215	199	201	199
query99	1370	1402	1287	1287
Total cold run time: 294253 ms
Total hot run time: 193426 ms

@doris-robot
Copy link

ClickBench: Total hot run time: 30.76 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 1ecf72ff8cd205eec59f4374a8182c1e981cb594, data reload: false

query1	0.06	0.03	0.03
query2	0.08	0.03	0.03
query3	0.25	0.07	0.07
query4	1.62	0.11	0.10
query5	0.42	0.41	0.41
query6	1.18	0.65	0.65
query7	0.02	0.02	0.02
query8	0.05	0.04	0.03
query9	0.60	0.50	0.51
query10	0.56	0.56	0.55
query11	0.15	0.11	0.11
query12	0.13	0.10	0.11
query13	0.61	0.59	0.59
query14	2.82	2.75	2.73
query15	0.89	0.82	0.81
query16	0.38	0.40	0.38
query17	1.07	1.06	1.07
query18	0.23	0.20	0.21
query19	1.90	1.87	1.98
query20	0.01	0.01	0.01
query21	15.36	0.89	0.58
query22	0.75	0.79	0.56
query23	15.42	1.42	0.58
query24	2.94	1.66	1.28
query25	0.23	0.15	0.04
query26	0.18	0.14	0.14
query27	0.07	0.06	0.04
query28	14.41	0.96	0.42
query29	12.57	3.95	3.25
query30	0.25	0.09	0.06
query31	2.83	0.58	0.36
query32	3.22	0.56	0.46
query33	3.08	3.17	3.06
query34	16.64	5.12	4.46
query35	4.51	4.47	4.44
query36	0.82	0.48	0.48
query37	0.09	0.06	0.06
query38	0.05	0.04	0.03
query39	0.03	0.02	0.02
query40	0.18	0.14	0.12
query41	0.08	0.03	0.02
query42	0.04	0.02	0.02
query43	0.03	0.03	0.03
Total cold run time: 106.81 s
Total hot run time: 30.76 s

@englefly
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

TPC-H: Total hot run time: 32550 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit a107908f3456c8e1c82f72d045d10b6dfaa300e2, data reload: false

------ Round 1 ----------------------------------
q1	17614	5674	5489	5489
q2	2057	311	174	174
q3	10481	1289	762	762
q4	10219	894	442	442
q5	7974	2236	2047	2047
q6	209	170	137	137
q7	933	764	606	606
q8	9257	1522	1303	1303
q9	5333	5024	5117	5024
q10	6814	2262	1793	1793
q11	481	283	263	263
q12	345	375	221	221
q13	17761	3714	3119	3119
q14	239	238	211	211
q15	510	462	456	456
q16	629	624	586	586
q17	590	904	336	336
q18	6877	6515	6487	6487
q19	1841	1047	570	570
q20	322	329	201	201
q21	3164	2233	2006	2006
q22	365	334	317	317
Total cold run time: 104015 ms
Total hot run time: 32550 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5683	5636	5622	5622
q2	252	332	232	232
q3	2239	2619	2317	2317
q4	1410	1821	1367	1367
q5	4328	4819	4758	4758
q6	184	161	128	128
q7	2067	1947	1805	1805
q8	2691	2878	2767	2767
q9	7388	7243	7295	7243
q10	3064	3284	2820	2820
q11	588	500	474	474
q12	665	739	581	581
q13	3630	3949	3255	3255
q14	289	300	277	277
q15	519	464	445	445
q16	658	681	642	642
q17	1270	1758	1277	1277
q18	7673	7448	7488	7448
q19	893	1267	1210	1210
q20	1996	2017	1938	1938
q21	5712	5210	4990	4990
q22	636	605	564	564
Total cold run time: 53835 ms
Total hot run time: 52160 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 195265 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit a107908f3456c8e1c82f72d045d10b6dfaa300e2, data reload: false

query1	1321	974	921	921
query2	6491	2258	2333	2258
query3	11110	4794	4898	4794
query4	33054	23284	23276	23276
query5	3649	628	482	482
query6	284	211	198	198
query7	3987	497	319	319
query8	287	237	222	222
query9	9295	2665	2656	2656
query10	441	304	253	253
query11	17630	15198	15107	15107
query12	156	105	103	103
query13	1539	529	399	399
query14	10213	7479	7349	7349
query15	256	210	189	189
query16	8020	614	508	508
query17	1553	791	618	618
query18	2133	436	323	323
query19	225	196	164	164
query20	127	117	116	116
query21	208	134	110	110
query22	4407	4425	4463	4425
query23	34276	32944	32913	32913
query24	6383	2443	2415	2415
query25	493	467	397	397
query26	785	281	162	162
query27	2137	471	339	339
query28	5346	2507	2467	2467
query29	653	553	418	418
query30	217	190	158	158
query31	928	887	841	841
query32	83	62	58	58
query33	485	359	304	304
query34	826	886	538	538
query35	814	836	723	723
query36	1041	1045	969	969
query37	120	96	81	81
query38	4383	4159	4250	4159
query39	1466	1435	1464	1435
query40	217	116	101	101
query41	53	54	50	50
query42	121	108	102	102
query43	524	511	505	505
query44	1322	844	833	833
query45	191	180	174	174
query46	889	1066	668	668
query47	1877	1881	1831	1831
query48	392	419	336	336
query49	723	507	395	395
query50	647	669	402	402
query51	7032	7187	7027	7027
query52	101	102	89	89
query53	233	248	184	184
query54	492	501	438	438
query55	80	91	79	79
query56	261	257	253	253
query57	1218	1205	1148	1148
query58	243	235	229	229
query59	3079	3227	3056	3056
query60	292	269	248	248
query61	120	115	111	111
query62	786	717	690	690
query63	235	192	190	190
query64	3525	1043	695	695
query65	3302	3271	3210	3210
query66	910	402	300	300
query67	16208	15818	15491	15491
query68	8800	737	517	517
query69	496	276	259	259
query70	1208	1086	1144	1086
query71	450	285	266	266
query72	6475	3910	3866	3866
query73	674	746	361	361
query74	10477	9202	8683	8683
query75	4363	3145	2666	2666
query76	3912	1135	781	781
query77	773	378	268	268
query78	9985	10019	9510	9510
query79	3627	807	595	595
query80	757	550	453	453
query81	494	274	233	233
query82	609	153	118	118
query83	192	172	155	155
query84	282	90	81	81
query85	771	342	298	298
query86	357	322	297	297
query87	4513	4304	4304	4304
query88	3389	2222	2176	2176
query89	423	329	292	292
query90	1923	188	192	188
query91	141	135	107	107
query92	64	56	50	50
query93	1966	861	523	523
query94	668	384	299	299
query95	339	256	254	254
query96	488	625	297	297
query97	2857	2963	2824	2824
query98	215	207	198	198
query99	1581	1340	1258	1258
Total cold run time: 295164 ms
Total hot run time: 195265 ms

@doris-robot
Copy link

ClickBench: Total hot run time: 31 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit a107908f3456c8e1c82f72d045d10b6dfaa300e2, data reload: false

query1	0.03	0.03	0.04
query2	0.07	0.03	0.03
query3	0.24	0.07	0.08
query4	1.62	0.10	0.10
query5	0.40	0.42	0.39
query6	1.18	0.65	0.65
query7	0.02	0.02	0.01
query8	0.05	0.03	0.03
query9	0.58	0.50	0.51
query10	0.56	0.56	0.55
query11	0.15	0.10	0.10
query12	0.14	0.10	0.11
query13	0.61	0.60	0.60
query14	2.74	2.73	2.74
query15	0.92	0.82	0.82
query16	0.39	0.38	0.39
query17	1.05	1.05	1.07
query18	0.23	0.22	0.20
query19	1.90	1.90	2.03
query20	0.02	0.02	0.01
query21	15.35	0.99	0.59
query22	0.76	0.88	0.67
query23	15.23	1.38	0.59
query24	2.95	1.16	1.24
query25	0.24	0.06	0.13
query26	0.19	0.15	0.14
query27	0.06	0.05	0.05
query28	14.04	0.97	0.44
query29	12.58	3.89	3.27
query30	0.25	0.09	0.06
query31	2.84	0.61	0.38
query32	3.22	0.55	0.46
query33	3.00	3.11	3.10
query34	16.61	5.14	4.51
query35	4.55	4.47	4.58
query36	0.61	0.49	0.48
query37	0.09	0.06	0.06
query38	0.04	0.04	0.03
query39	0.04	0.03	0.02
query40	0.18	0.13	0.13
query41	0.08	0.03	0.03
query42	0.03	0.02	0.02
query43	0.04	0.04	0.03
Total cold run time: 105.88 s
Total hot run time: 31 s

@github-actions
Copy link
Contributor

PR approved by at least one committer and no changes requested.

@github-actions github-actions bot added approved Indicates a PR has been approved by one committer. reviewed labels Jan 15, 2025
@github-actions
Copy link
Contributor

PR approved by anyone and no changes requested.

@englefly englefly merged commit aeebe49 into apache:master Jan 15, 2025
25 of 26 checks passed
@englefly englefly deleted the col-prun-agg-cse branch January 15, 2025 10:01
github-actions bot pushed a commit that referenced this pull request Jan 15, 2025
…agg (#46627)

### What problem does this PR solve?

after extracting common expressions for agg, the underlying projection
may project redundant columns.
for example:
original plan 
Agg(groupkey=[A+B, A+B+1])
--> project(A, B)

after extracting, "A+B as C" is detected as a common expression, and the
plan becomes
Agg(groupKey=[C, C+1])
 -->project(A, B, A+B as C)

here A, B should not be projected, since they are not used any more. so
the optimal plan is
Agg(groupKey=[C, C+1])
 -->project(A+B as C)

Related PR: #40473
lzyy2024 pushed a commit to lzyy2024/doris that referenced this pull request Feb 21, 2025
…agg (apache#46627)

### What problem does this PR solve?

after extracting common expressions for agg, the underlying projection
may project redundant columns.
for example:
original plan 
Agg(groupkey=[A+B, A+B+1])
--> project(A, B)

after extracting, "A+B as C" is detected as a common expression, and the
plan becomes
Agg(groupKey=[C, C+1])
 -->project(A, B, A+B as C)

here A, B should not be projected, since they are not used any more. so
the optimal plan is
Agg(groupKey=[C, C+1])
 -->project(A+B as C)

Related PR: apache#40473
@morrySnow morrySnow added the p0_b label Feb 24, 2025
dataroaring pushed a commit that referenced this pull request Feb 25, 2025
…column from agg #46627 (#47029)

Cherry-picked from #46627

Co-authored-by: minghong <zhouminghong@selectdb.com>
@gavinchou gavinchou mentioned this pull request Apr 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. dev/3.0.5-merged p0_b reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants