924060929 opened a new pull request, #70994:
URL: https://github.com/apache/doris/pull/70994

   ### Background
   
   Sampled OLAP column statistics collection runs a whole-index `SELECT 
MIN(col), MAX(col)` query per column task before running the sampled statistics 
query. On wide tables this schedules one separate internal query per column, 
and on aggregate-key tables non-key value columns cannot use zone-map pushdown 
and scan the index repeatedly.
   
   ### What problem does this PR solve?
   
   Issue Number: None
   Related PR: None
   PR Type: Performance
   
   Problem Summary:
   
   Group eligible table-sample OLAP tasks in an `AnalysisJob` by target index 
and column aggregation status, and execute bounded multi-column `MIN`/`MAX` 
queries (up to 64 columns per batch by default) instead of one query per 
column. Separate key/non-aggregated columns from aggregate value columns so 
zone-map pushdown remains intact, serialize heavy aggregate-value batches per 
job, and fall back to per-column queries on ordinary batch failures while 
isolating single-task cancellation from sibling tasks.
   
   ### Details
   
   - **Change map:** ~310 lines production FE code 
(`ColumnMinMaxBatchCollector`, `OlapAnalysisTask`, `AnalysisJob`, 
`AnalysisManager`, `BaseAnalysisTask`, `SessionVariable`, `StatisticsUtil`), 
~680 lines JUnit 5 and regression tests.
   - **Why it was slow:** Each sampled column scheduled its own `MIN`/`MAX` 
query over the full index, multiplying planning/RPC overhead on wide tables and 
repeating full data scans across aggregate value columns.
   - **Optimization:** Snapshot eligible table-sample OLAP columns at job 
creation, partition them by `(indexId, column.isAggregated())` into batches of 
`statistics_minmax_batch_columns` (default 64), and run each batch inline on 
the first requesting worker without re-submitting to the analysis thread pool.
   - **Results:** Unit tests verify 64 columns in one group execute 1 bounds 
query and 100 columns execute 2 queries instead of 64/100; single-task 
cancellation leaves live siblings unaffected and job-wide cancellation triggers 
0 fallback queries.
   - **Applicability and cost:** Applies to non-empty OLAP table-sample tasks 
known at job creation; tasks switching to sampling mid-partition-analyze retain 
individual bounds queries. Setting `GLOBAL statistics_minmax_batch_columns <= 
1` restores single-column queries for subsequent jobs.
   
   ### Testing
   
   Ran `./run-fe-ut.sh` covering 8 statistics analysis test classes (141 tests 
passed, including 45 new cases in `ColumnMinMaxBatchCollectorTest` for 
batching, index/aggregation isolation, literal escaping, single-worker sync 
execution, single-task vs job-wide cancellation, and fallback) and `mvn 
checkstyle:check -pl fe-core` (0 violations). Ran 
`regression-test/suites/statistics/test_sample_minmax_batch.groovy` on a local 
FE+BE cluster (passed).
   
   ### Release note
   
   Sample statistics collection now batches whole-index min/max queries across 
columns (`statistics_minmax_batch_columns`, default 64).
   
   ### Check List (For Author)
   
   - Behavior changed: No
   - Does this need documentation: Yes (global variable 
`statistics_minmax_batch_columns`)
   - Pre-submission status: Ready
   
   ### AI Disclosure
   
   - Tool: Antigravity & Codex
   - Generated: FE implementation, unit/regression tests, and commit description
   - Human review: Reviewed concurrency state machine, cancellation isolation, 
SQL literal compatibility, and PR scope boundaries
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to