Skip to content

[opt](nereids) compare str literal as date literal to compute selectivity#35610

Merged
englefly merged 2 commits into
apache:masterfrom
englefly:str-date
May 30, 2024
Merged

[opt](nereids) compare str literal as date literal to compute selectivity#35610
englefly merged 2 commits into
apache:masterfrom
englefly:str-date

Conversation

@englefly

@englefly englefly commented May 29, 2024

Copy link
Copy Markdown
Contributor

this pr improves #34542, when the real data type is date-like type.

Some users are likely to define date(datetime) column as Varchar type.
when estimating the selectivity of predicate like A>'2020-01-01', if nereids regards A and '2020-01-01' as date type, the sel is more accurate than that as string type.

@doris-robot

Copy link
Copy Markdown

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

Since 2024-03-18, the Document has been moved to doris-website.
See Doris Document.

@englefly

Copy link
Copy Markdown
Contributor Author

run buildall

@morrySnow morrySnow added usercase Important user case type label dev/2.0.x dev/2.1.x labels May 29, 2024
Comment thread fe/fe-core/src/main/java/org/apache/doris/nereids/stats/FilterEstimation.java Outdated
Comment thread fe/fe-core/src/main/java/org/apache/doris/nereids/stats/FilterEstimation.java Outdated
@doris-robot

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

------ Round 1 ----------------------------------
q1	17607	4453	4309	4309
q2	2037	206	210	206
q3	10456	1235	1193	1193
q4	10196	833	937	833
q5	7486	2766	2747	2747
q6	222	133	139	133
q7	974	622	630	622
q8	9220	2142	2107	2107
q9	9021	6714	6727	6714
q10	9305	3924	3857	3857
q11	452	245	275	245
q12	442	230	226	226
q13	17363	3199	3259	3199
q14	283	212	231	212
q15	517	466	487	466
q16	492	401	387	387
q17	1006	697	746	697
q18	8502	7821	7847	7821
q19	6039	1611	1571	1571
q20	630	366	324	324
q21	5286	3350	4178	3350
q22	403	339	342	339
Total cold run time: 117939 ms
Total hot run time: 41558 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4603	4425	4415	4415
q2	372	269	266	266
q3	3128	2882	2954	2882
q4	1971	1615	1600	1600
q5	5443	5557	5513	5513
q6	212	126	127	126
q7	2152	1830	1789	1789
q8	3232	3392	3419	3392
q9	8655	8723	8689	8689
q10	4074	3771	3738	3738
q11	601	496	493	493
q12	814	626	647	626
q13	16897	3169	3273	3169
q14	309	274	277	274
q15	526	503	465	465
q16	497	448	432	432
q17	1817	1488	1470	1470
q18	7679	7593	7418	7418
q19	1691	1574	1598	1574
q20	2019	1767	1811	1767
q21	10014	4784	4900	4784
q22	603	534	526	526
Total cold run time: 77309 ms
Total hot run time: 55408 ms

@doris-robot

Copy link
Copy Markdown
TPC-DS: Total hot run time: 172489 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 0522568df7318dfb3318b01ffe3d2f8ce1828c33, data reload: false

query1	914	375	375	375
query2	6447	2503	2317	2317
query3	6633	215	214	214
query4	19568	17450	17248	17248
query5	4092	444	427	427
query6	254	156	155	155
query7	4589	301	292	292
query8	312	304	280	280
query9	8675	2402	2396	2396
query10	447	285	268	268
query11	10610	9892	9953	9892
query12	143	93	87	87
query13	1651	390	365	365
query14	9531	7087	7376	7087
query15	233	190	190	190
query16	7644	265	257	257
query17	1710	537	518	518
query18	1943	279	275	275
query19	197	155	151	151
query20	91	85	86	85
query21	198	129	131	129
query22	4320	3944	3788	3788
query23	33540	32942	32745	32745
query24	9282	2834	2842	2834
query25	565	359	350	350
query26	699	162	164	162
query27	2183	328	334	328
query28	5804	2116	2082	2082
query29	849	607	617	607
query30	209	150	153	150
query31	968	775	725	725
query32	91	54	53	53
query33	639	265	266	265
query34	900	467	476	467
query35	709	604	588	588
query36	1103	904	940	904
query37	104	68	66	66
query38	2877	2762	2759	2759
query39	875	804	786	786
query40	194	124	124	124
query41	53	55	49	49
query42	104	98	101	98
query43	593	560	565	560
query44	1118	742	755	742
query45	183	174	168	168
query46	1072	721	715	715
query47	1853	1741	1763	1741
query48	385	295	302	295
query49	857	400	411	400
query50	778	385	394	385
query51	6844	6723	6697	6697
query52	106	103	92	92
query53	360	305	298	298
query54	829	442	436	436
query55	81	74	75	74
query56	273	267	260	260
query57	1095	1043	1057	1043
query58	234	225	218	218
query59	3527	3266	3262	3262
query60	295	336	271	271
query61	92	85	90	85
query62	611	448	468	448
query63	320	291	292	291
query64	8500	2228	1691	1691
query65	3206	3116	3154	3116
query66	774	322	333	322
query67	15138	15033	14934	14934
query68	4568	555	548	548
query69	445	272	271	271
query70	1213	1148	1162	1148
query71	385	271	273	271
query72	7684	5701	5611	5611
query73	711	327	324	324
query74	5967	5596	5590	5590
query75	3299	2622	2646	2622
query76	2251	1046	1027	1027
query77	401	272	271	271
query78	10233	9982	9791	9791
query79	2055	532	514	514
query80	1335	431	425	425
query81	545	221	226	221
query82	754	94	91	91
query83	246	174	169	169
query84	244	86	85	85
query85	2047	270	312	270
query86	486	299	323	299
query87	3255	3109	3125	3109
query88	4188	2315	2325	2315
query89	499	402	392	392
query90	2055	189	187	187
query91	126	97	93	93
query92	65	49	50	49
query93	2717	524	514	514
query94	1299	189	187	187
query95	401	302	303	302
query96	591	263	260	260
query97	3274	3057	2989	2989
query98	238	221	221	221
query99	1137	841	865	841
Total cold run time: 265788 ms
Total hot run time: 172489 ms

@doris-robot

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

query1	0.04	0.03	0.03
query2	0.08	0.04	0.04
query3	0.23	0.04	0.04
query4	1.69	0.07	0.07
query5	0.52	0.49	0.56
query6	1.13	0.73	0.72
query7	0.02	0.01	0.01
query8	0.06	0.04	0.04
query9	0.54	0.49	0.48
query10	0.55	0.55	0.54
query11	0.15	0.12	0.12
query12	0.16	0.12	0.12
query13	0.59	0.59	0.60
query14	0.78	0.77	0.78
query15	0.83	0.81	0.82
query16	0.35	0.36	0.37
query17	0.96	0.99	1.02
query18	0.23	0.24	0.25
query19	1.82	1.71	1.71
query20	0.01	0.01	0.01
query21	15.44	0.73	0.69
query22	4.36	6.95	1.80
query23	18.34	1.40	1.26
query24	1.30	0.40	0.26
query25	0.14	0.09	0.07
query26	0.25	0.17	0.16
query27	0.08	0.07	0.08
query28	13.36	1.01	0.99
query29	12.76	3.38	3.32
query30	0.24	0.06	0.05
query31	2.89	0.38	0.39
query32	3.30	0.46	0.46
query33	2.89	2.83	2.91
query34	17.19	4.46	4.39
query35	4.44	4.50	4.56
query36	0.70	0.47	0.47
query37	0.17	0.16	0.15
query38	0.16	0.14	0.14
query39	0.04	0.03	0.04
query40	0.16	0.14	0.14
query41	0.09	0.05	0.05
query42	0.06	0.04	0.05
query43	0.04	0.04	0.04
Total cold run time: 109.14 s
Total hot run time: 30.47 s

@englefly

Copy link
Copy Markdown
Contributor Author

run buildall

@doris-robot

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

------ Round 1 ----------------------------------
q1	17622	5088	4350	4350
q2	2038	196	190	190
q3	10549	1163	1178	1163
q4	10206	826	780	780
q5	7516	2831	2667	2667
q6	219	131	138	131
q7	972	618	609	609
q8	9228	2171	2123	2123
q9	9537	6826	6748	6748
q10	9347	4001	3913	3913
q11	440	241	247	241
q12	546	222	226	222
q13	18226	3117	3201	3117
q14	262	216	229	216
q15	536	477	493	477
q16	502	393	395	393
q17	1031	772	756	756
q18	8798	7870	7834	7834
q19	6770	1666	1591	1591
q20	644	328	317	317
q21	5431	4115	4092	4092
q22	386	329	323	323
Total cold run time: 120806 ms
Total hot run time: 42253 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4547	4421	4436	4421
q2	373	275	274	274
q3	3237	3043	2790	2790
q4	1861	1625	1694	1625
q5	5489	5553	5480	5480
q6	228	126	128	126
q7	2269	1836	1833	1833
q8	3278	3399	3366	3366
q9	8763	8822	8699	8699
q10	3998	3869	3951	3869
q11	592	496	502	496
q12	805	606	623	606
q13	16790	3207	3151	3151
q14	293	269	267	267
q15	530	487	481	481
q16	500	419	412	412
q17	1860	1540	1474	1474
q18	7850	7644	7463	7463
q19	1671	1613	1634	1613
q20	2013	1834	1794	1794
q21	5000	4808	4761	4761
q22	571	539	508	508
Total cold run time: 72518 ms
Total hot run time: 55509 ms

@github-actions github-actions Bot added the approved Indicates a PR has been approved by one committer. label May 30, 2024
@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions

Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

@doris-robot

Copy link
Copy Markdown
TPC-DS: Total hot run time: 171106 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 5f5714e4b2ab2cf1ac0dbb867d0afcbc09ccbef8, data reload: false

query1	936	390	373	373
query2	7575	2539	2244	2244
query3	6660	211	208	208
query4	19140	17492	17240	17240
query5	4110	419	420	419
query6	249	180	150	150
query7	4603	292	294	292
query8	331	283	278	278
query9	8716	2361	2358	2358
query10	454	302	272	272
query11	10583	10074	9999	9999
query12	156	92	86	86
query13	1638	359	349	349
query14	9289	6980	7644	6980
query15	231	184	187	184
query16	7134	265	269	265
query17	1014	521	527	521
query18	1836	266	266	266
query19	202	162	156	156
query20	93	88	85	85
query21	201	137	134	134
query22	4234	4121	3972	3972
query23	33466	32908	32689	32689
query24	5062	2818	2870	2818
query25	466	350	361	350
query26	691	154	157	154
query27	1834	326	317	317
query28	3814	2069	2047	2047
query29	844	599	591	591
query30	205	151	154	151
query31	930	768	745	745
query32	62	56	56	56
query33	471	263	259	259
query34	860	470	473	470
query35	709	596	612	596
query36	1015	911	908	908
query37	100	70	66	66
query38	2815	2737	2738	2737
query39	847	803	775	775
query40	198	127	124	124
query41	57	53	53	53
query42	107	98	98	98
query43	607	535	560	535
query44	1070	722	767	722
query45	189	168	175	168
query46	1040	746	698	698
query47	1813	1740	1752	1740
query48	381	294	296	294
query49	755	376	386	376
query50	768	379	384	379
query51	6786	6744	6644	6644
query52	108	91	94	91
query53	359	288	294	288
query54	539	426	430	426
query55	76	72	74	72
query56	261	239	264	239
query57	1084	1037	1024	1024
query58	221	207	234	207
query59	3466	3327	3290	3290
query60	272	253	260	253
query61	89	85	87	85
query62	549	456	484	456
query63	313	291	286	286
query64	2570	1784	1680	1680
query65	3246	3080	3136	3080
query66	774	328	330	328
query67	15391	14634	14776	14634
query68	4485	542	534	534
query69	442	278	266	266
query70	1185	1060	1077	1060
query71	391	268	276	268
query72	7728	5594	5161	5161
query73	719	319	317	317
query74	5999	5521	5569	5521
query75	3294	2612	2631	2612
query76	2306	1028	994	994
query77	376	260	266	260
query78	10196	9741	9717	9717
query79	2338	513	522	513
query80	1043	440	440	440
query81	524	222	217	217
query82	740	96	90	90
query83	249	168	173	168
query84	270	90	84	84
query85	1145	293	377	293
query86	463	321	318	318
query87	3293	3082	3092	3082
query88	4167	2330	2314	2314
query89	485	401	379	379
query90	2032	186	195	186
query91	125	97	98	97
query92	60	51	51	51
query93	2244	504	499	499
query94	1124	184	191	184
query95	408	313	312	312
query96	592	268	271	268
query97	3138	3065	3027	3027
query98	240	218	215	215
query99	1177	843	829	829
Total cold run time: 249643 ms
Total hot run time: 171106 ms

@doris-robot

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

query1	0.04	0.03	0.03
query2	0.08	0.04	0.04
query3	0.23	0.06	0.05
query4	1.68	0.07	0.08
query5	0.50	0.47	0.48
query6	1.13	0.72	0.72
query7	0.02	0.01	0.02
query8	0.05	0.05	0.04
query9	0.53	0.48	0.48
query10	0.55	0.57	0.54
query11	0.16	0.11	0.11
query12	0.14	0.12	0.12
query13	0.59	0.59	0.60
query14	0.77	0.78	0.75
query15	0.83	0.82	0.80
query16	0.36	0.37	0.37
query17	0.96	1.02	1.00
query18	0.22	0.22	0.26
query19	1.74	1.79	1.79
query20	0.01	0.01	0.01
query21	15.60	0.67	0.66
query22	4.03	7.78	1.96
query23	18.36	1.36	1.23
query24	1.87	0.26	0.20
query25	0.15	0.08	0.08
query26	0.27	0.17	0.16
query27	0.08	0.07	0.08
query28	13.32	1.01	1.00
query29	13.52	3.33	3.32
query30	0.23	0.06	0.05
query31	2.87	0.39	0.38
query32	3.29	0.47	0.47
query33	2.88	2.88	2.90
query34	17.23	4.40	4.44
query35	4.48	4.52	4.58
query36	0.68	0.47	0.48
query37	0.18	0.15	0.16
query38	0.15	0.15	0.15
query39	0.04	0.04	0.04
query40	0.16	0.15	0.14
query41	0.09	0.05	0.04
query42	0.05	0.05	0.04
query43	0.04	0.04	0.03
Total cold run time: 110.16 s
Total hot run time: 30.65 s

@englefly englefly merged commit a4691fc into apache:master May 30, 2024
@englefly englefly deleted the str-date branch May 30, 2024 06:32
englefly added a commit to englefly/incubator-doris that referenced this pull request May 30, 2024
englefly added a commit to englefly/incubator-doris that referenced this pull request May 30, 2024
yiguolei pushed a commit that referenced this pull request May 30, 2024
…vity (#35610)

this pr improves #34542, when the real data type is date-like type.

Some users are likely to define date(datetime) column as Varchar type.
when estimating the selectivity of predicate like A>'2020-01-01', if
nereids regards A and '2020-01-01' as date type, the sel is more
accurate than that as string type.
englefly added a commit to englefly/incubator-doris that referenced this pull request May 31, 2024
dataroaring pushed a commit that referenced this pull request May 31, 2024
…vity (#35610)

this pr improves #34542, when the real data type is date-like type.

Some users are likely to define date(datetime) column as Varchar type.
when estimating the selectivity of predicate like A>'2020-01-01', if
nereids regards A and '2020-01-01' as date type, the sel is more
accurate than that as string type.
xiaokang pushed a commit that referenced this pull request Jun 2, 2024
… (#35667)

Some users are likely to define date(datetime) column as Varchar type.
when estimating the selectivity of predicate like A>'2020-01-01', if
nereids regards A and '2020-01-01' as date type, the sel is more
accurate than that as string type.
mongo360 pushed a commit to mongo360/doris that referenced this pull request Aug 16, 2024
…apache#34542 (apache#35667)

Some users are likely to define date(datetime) column as Varchar type.
when estimating the selectivity of predicate like A>'2020-01-01', if
nereids regards A and '2020-01-01' as date type, the sel is more
accurate than that as string type.
englefly added a commit that referenced this pull request Aug 28, 2025
### What problem does this PR solve?
in #35610, we try to estimate string column as date column to improve
estimation accuracy, since many users define a date value column as
string.
after estimation, we need to convert min/maxExpr from date literal to
string literal. we checked minExpr != null && maxExpr!=null.
But after #54035, the column stats may be minExpr != null but maxExpr ==
null. and this leads to NPE.
HappenLee pushed a commit to HappenLee/incubator-doris that referenced this pull request Apr 24, 2026
…vity (apache#35610)

this pr improves apache#34542, when the real data type is date-like type.

Some users are likely to define date(datetime) column as Varchar type.
when estimating the selectivity of predicate like A>'2020-01-01', if
nereids regards A and '2020-01-01' as date type, the sel is more
accurate than that as string type.
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/2.0.11-merged dev/2.1.4-merged dev/3.0.0-merged reviewed usercase Important user case type label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants