Skip to content

[opt](exec) skip result serialization for dry run queries#63356

Open
Mryange wants to merge 1 commit into
apache:masterfrom
Mryange:skip-result-serialization-for-dry-run
Open

[opt](exec) skip result serialization for dry run queries#63356
Mryange wants to merge 1 commit into
apache:masterfrom
Mryange:skip-result-serialization-for-dry-run

Conversation

@Mryange
Copy link
Copy Markdown
Contributor

@Mryange Mryange commented May 18, 2026

What problem does this PR solve?

Issue Number: N/A

Related PR: None

Problem Summary:
When dry_run_query is enabled, FE only needs the returned row count, but BE still spends most of PhysicalResultSink time serializing MySQL result rows In a local dry-run case against numbers("number"="1000000"), the profile showed AppendBatchTime = 77.689ms, TupleConvertTime = 68.650ms, and ResultSendTime = 2.702us, which means the dry-run path was still paying almost the full result sink conversion cost.

This change keeps output expr evaluation intact, but returns early in the MySQL result writers once the output block is produced in dry-run mode. That preserves returned row accounting while skipping result serialization, block copy, and sink enqueue work that dry-run queries never consume.

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

@Mryange
Copy link
Copy Markdown
Contributor Author

Mryange commented May 18, 2026

/review

@hello-stephen
Copy link
Copy Markdown
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?

@Mryange
Copy link
Copy Markdown
Contributor Author

Mryange commented May 18, 2026

run buildall

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

No blocking issues found in the actual PR diff. The dry-run fast path now still evaluates output expressions, counts written rows, and skips result serialization/enqueue for both MySQL and Arrow Flight writers, which matches the stated goal and avoids the previous serialization cost. The MySQL unit test covers both normal and dry-run queue behavior; Arrow Flight has analogous logic but no dedicated test in this PR, which is a residual coverage gap rather than a blocker.\n\nCritical checkpoint conclusions: goal is clear and implemented for the touched writers; the change is small and focused. No new concurrency, lifecycle, persistence, storage-format, or dynamic-config concerns were found. Parallel writer paths were both updated. Error propagation remains unchanged around expression evaluation. Test coverage exists for the MySQL path, but Arrow Flight dry-run behavior is not directly tested. No additional user-provided focus points were supplied.

@hello-stephen
Copy link
Copy Markdown
Contributor

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

------ Round 1 ----------------------------------
orders	Doris	NULL	NULL	0	0	0	NULL	0	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	17755	3904	3815	3815
q2	q3	10776	1367	777	777
q4	4688	482	342	342
q5	7699	2258	2100	2100
q6	233	174	135	135
q7	959	788	640	640
q8	9359	1733	1614	1614
q9	5163	4890	4851	4851
q10	6412	2067	1786	1786
q11	432	264	242	242
q12	621	411	290	290
q13	18138	3373	2799	2799
q14	262	256	242	242
q15	q16	818	774	706	706
q17	989	1037	920	920
q18	6829	5673	5598	5598
q19	1310	1348	1031	1031
q20	502	407	439	407
q21	6343	2851	2724	2724
q22	463	401	385	385
Total cold run time: 99751 ms
Total hot run time: 31404 ms

----- Round 2, with runtime_filter_mode=off -----
orders	Doris	NULL	NULL	150000000	42	6422171781	NULL	22778155	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	4617	4622	4565	4565
q2	q3	4842	5301	4634	4634
q4	2118	2211	1397	1397
q5	5029	4769	4654	4654
q6	237	176	142	142
q7	1952	1796	1612	1612
q8	2438	2103	2180	2103
q9	7731	7414	7396	7396
q10	4541	4501	4042	4042
q11	526	372	348	348
q12	705	728	503	503
q13	3042	3438	2760	2760
q14	263	276	255	255
q15	q16	669	690	618	618
q17	1264	1228	1213	1213
q18	7161	6922	6648	6648
q19	1108	1074	1083	1074
q20	2202	2219	1924	1924
q21	5301	4616	4472	4472
q22	509	476	409	409
Total cold run time: 56255 ms
Total hot run time: 50769 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 62.50% (5/8) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 73.56% (27804/37799)
Line Coverage 57.49% (301080/523719)
Region Coverage 54.88% (252367/459834)
Branch Coverage 56.26% (108787/193348)

@hello-stephen
Copy link
Copy Markdown
Contributor

TPC-DS: Total hot run time: 169944 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 176fa8a9be1ba2a6c984334c2abdbf9435fd2669, data reload: false

query5	4309	667	527	527
query6	333	216	200	200
query7	4214	561	314	314
query8	327	236	235	235
query9	8916	4006	4030	4006
query10	441	334	296	296
query11	5738	2427	2237	2237
query12	181	126	122	122
query13	1269	614	435	435
query14	6023	5359	5064	5064
query14_1	4375	4412	4389	4389
query15	215	202	179	179
query16	987	473	443	443
query17	1139	704	586	586
query18	2483	484	356	356
query19	212	200	161	161
query20	142	131	130	130
query21	210	140	124	124
query22	13559	13557	13440	13440
query23	17324	16389	15939	15939
query23_1	16202	16081	16071	16071
query24	7470	1743	1306	1306
query24_1	1298	1306	1285	1285
query25	545	480	434	434
query26	1295	329	181	181
query27	2737	550	341	341
query28	4449	1972	1934	1934
query29	1013	622	494	494
query30	298	238	196	196
query31	1141	1075	932	932
query32	98	77	75	75
query33	563	344	298	298
query34	1182	1101	620	620
query35	765	778	685	685
query36	1348	1323	1165	1165
query37	155	106	90	90
query38	3251	3126	3060	3060
query39	934	908	886	886
query39_1	886	903	898	898
query40	223	146	123	123
query41	64	63	62	62
query42	110	109	108	108
query43	322	327	284	284
query44	
query45	212	201	191	191
query46	1055	1174	764	764
query47	2281	2312	2191	2191
query48	399	382	302	302
query49	634	490	387	387
query50	985	337	260	260
query51	4279	4276	4180	4180
query52	106	105	94	94
query53	257	285	204	204
query54	322	279	256	256
query55	92	91	84	84
query56	310	294	303	294
query57	1423	1414	1315	1315
query58	302	271	273	271
query59	1551	1602	1450	1450
query60	324	319	316	316
query61	158	159	161	159
query62	664	614	550	550
query63	249	206	208	206
query64	2469	837	739	739
query65	
query66	1728	490	363	363
query67	30031	29967	29252	29252
query68	
query69	474	341	306	306
query70	1024	990	954	954
query71	301	275	272	272
query72	2988	2693	2397	2397
query73	860	745	406	406
query74	5084	4917	4719	4719
query75	2682	2591	2262	2262
query76	2291	1143	735	735
query77	399	413	326	326
query78	12136	12088	11799	11799
query79	1303	1030	760	760
query80	640	557	476	476
query81	454	281	246	246
query82	244	163	125	125
query83	274	285	266	266
query84	278	141	113	113
query85	960	619	535	535
query86	373	330	343	330
query87	3396	3404	3250	3250
query88	3523	2674	2655	2655
query89	433	403	346	346
query90	2182	179	188	179
query91	190	188	154	154
query92	80	80	77	77
query93	1504	1464	850	850
query94	542	389	331	331
query95	728	385	352	352
query96	1012	736	340	340
query97	2682	2687	2575	2575
query98	238	245	228	228
query99	1093	1125	972	972
Total cold run time: 251842 ms
Total hot run time: 169944 ms

@Mryange Mryange force-pushed the skip-result-serialization-for-dry-run branch from 176fa8a to cf8e0d3 Compare May 18, 2026 12:45
@Mryange
Copy link
Copy Markdown
Contributor Author

Mryange commented May 18, 2026

/review

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Review result: no blocking issues found in the live PR diff. The change keeps dry-run MySQL result writes executing output expressions while skipping serialization/enqueue, and the added unit path verifies no result batch is queued while written rows are still counted. Critical checkpoints: goal/test coverage satisfied for the dry-run skip behavior; scope is small and focused; no new concurrency, lifecycle, config, compatibility, transaction, persistence, or observability concerns identified; no parallel path requiring updates found; test coverage is targeted. User focus: no additional user-provided review focus was supplied.

@Mryange
Copy link
Copy Markdown
Contributor Author

Mryange commented May 18, 2026

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

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

------ Round 1 ----------------------------------
orders	Doris	NULL	NULL	0	0	0	NULL	0	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	17634	3874	3865	3865
q2	q3	10752	1355	821	821
q4	4680	468	344	344
q5	7579	2219	2084	2084
q6	237	172	135	135
q7	975	746	642	642
q8	9385	1637	1509	1509
q9	6378	4923	4854	4854
q10	6465	2099	1772	1772
q11	447	277	249	249
q12	701	423	294	294
q13	18243	3363	2785	2785
q14	265	255	230	230
q15	q16	813	778	700	700
q17	1022	846	886	846
q18	6900	5705	5530	5530
q19	1220	1197	1066	1066
q20	511	409	258	258
q21	5806	2544	2379	2379
q22	452	359	304	304
Total cold run time: 100465 ms
Total hot run time: 30667 ms

----- Round 2, with runtime_filter_mode=off -----
orders	Doris	NULL	NULL	150000000	42	6422171781	NULL	22778155	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	4239	4122	4132	4122
q2	q3	4531	4939	4362	4362
q4	2398	2226	1390	1390
q5	4389	4270	4326	4270
q6	224	175	127	127
q7	2131	1834	1643	1643
q8	2554	2190	2071	2071
q9	7797	7893	7841	7841
q10	4520	4469	4022	4022
q11	579	423	369	369
q12	719	739	522	522
q13	3386	3701	2952	2952
q14	307	290	288	288
q15	q16	736	737	670	670
q17	1331	1314	1324	1314
q18	7947	7295	7036	7036
q19	1094	1078	1098	1078
q20	2219	2218	1918	1918
q21	5343	4611	4479	4479
q22	522	480	435	435
Total cold run time: 56966 ms
Total hot run time: 50909 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

TPC-DS: Total hot run time: 169209 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 cf8e0d377f942e2cf32ca79a015d8682afbad76e, data reload: false

query5	4363	659	499	499
query6	344	218	199	199
query7	4262	583	296	296
query8	320	226	212	212
query9	8810	3961	3979	3961
query10	458	336	290	290
query11	5784	2370	2248	2248
query12	185	134	131	131
query13	1310	583	418	418
query14	5998	5338	5035	5035
query14_1	4364	4404	4303	4303
query15	211	201	178	178
query16	1003	450	427	427
query17	1138	716	586	586
query18	2530	472	351	351
query19	219	204	161	161
query20	134	129	129	129
query21	216	140	116	116
query22	13644	13521	13426	13426
query23	17202	16388	16021	16021
query23_1	16178	16224	16221	16221
query24	7486	1746	1272	1272
query24_1	1284	1301	1284	1284
query25	538	467	417	417
query26	1173	333	164	164
query27	2686	564	338	338
query28	4434	2027	1894	1894
query29	986	613	489	489
query30	307	240	199	199
query31	1117	1053	942	942
query32	92	81	70	70
query33	552	349	297	297
query34	1161	1118	643	643
query35	768	788	671	671
query36	1337	1308	1180	1180
query37	152	100	93	93
query38	3201	3146	3033	3033
query39	939	934	908	908
query39_1	893	875	881	875
query40	228	144	120	120
query41	64	62	61	61
query42	111	107	106	106
query43	318	332	288	288
query44	
query45	213	203	205	203
query46	1067	1181	712	712
query47	2262	2407	2214	2214
query48	373	425	299	299
query49	671	500	380	380
query50	1049	359	243	243
query51	4308	4302	4252	4252
query52	103	104	94	94
query53	261	285	204	204
query54	310	266	246	246
query55	91	93	84	84
query56	300	327	309	309
query57	1431	1442	1374	1374
query58	298	274	257	257
query59	1597	1710	1492	1492
query60	329	330	305	305
query61	163	161	174	161
query62	685	644	570	570
query63	245	200	204	200
query64	2245	815	643	643
query65	
query66	1701	480	352	352
query67	29980	29940	29832	29832
query68	
query69	467	335	305	305
query70	998	967	950	950
query71	302	273	265	265
query72	3016	2876	2664	2664
query73	820	762	431	431
query74	5098	4925	4776	4776
query75	2711	2585	2273	2273
query76	2305	1137	753	753
query77	409	408	344	344
query78	12092	12196	11603	11603
query79	1428	1068	696	696
query80	686	576	488	488
query81	453	278	241	241
query82	1307	162	126	126
query83	360	283	268	268
query84	275	145	118	118
query85	989	613	537	537
query86	393	330	344	330
query87	3391	3380	3247	3247
query88	3495	2641	2594	2594
query89	446	383	336	336
query90	1850	172	172	172
query91	181	175	140	140
query92	83	76	74	74
query93	1527	1502	859	859
query94	549	349	328	328
query95	661	467	349	349
query96	1018	801	328	328
query97	2708	2711	2568	2568
query98	238	227	231	227
query99	1119	1110	950	950
Total cold run time: 252586 ms
Total hot run time: 169209 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100.00% (4/4) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 73.60% (27825/37804)
Line Coverage 57.54% (301359/523745)
Region Coverage 54.85% (252221/459847)
Branch Coverage 56.35% (108948/193352)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants