Repository navigation
Conversation
|
Workflow [PR], commit [7fa0f2b] Summary: ❌
AI ReviewSummaryThis PR adds a Findings
Tests
Final Verdict
LLVM Coverage ReportMeasured on commit 7fa0f2b.
Changed lines: Changed C/C++ lines covered: 46/51 (90.20%) · Uncovered code |
|
Performance improvements:
I also got two regressions but these code paths are not changed:
Measurements obtained by running the new xml performance test files against both 8a863a7 (baseline, master) and f15a0e0. |
|
📊 Cloud Performance Report ✅ AI verdict: no significant changes detected. K_source=6 K_base=30 flagged=0/65 clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 33/37 (89.19%) · Uncovered code |
| @@ -0,0 +1,230 @@ | |||
| -- Tags: no-fasttest | |||
There was a problem hiding this comment.
This PR implements a performance optimization. The PR also includes a performance test (good). Do we really need a functional test then? The effects of statistics are only indirectly observable, and below test goes great lengths (complexity) because of that.
(asking because the test still fails in CI, and we could simplify our lives by omitting the test)
There was a problem hiding this comment.
We still need one semantic regression in addition to the performance test, but it does not have to be SQL if SQL cannot observe the exact estimate precisely enough.
This change is not only about insert speed; it changes the countmin equality counts that ConditionSelectivityEstimator consumes. The current PREWHERE-ordering test is too coarse for that contract: in the sliced-dictionary fixture, lc_value = 42 still sorts after selective_probe = 1 whether the estimate is the correct 3 or a biased 4, and lc_value = 5 still sorts before the 10 KB payload column because MergeTreeWhereOptimizer falls back to columns_size when selectivities tie or are close. If there is no stable SQL surface for exact estimateEqual values, restoring the small direct gtest is the practical way to pin the behavior.
|
Dear @rschu1ze, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
countmin statistics: optimize creation for LowCardinality columns
|
@cv4g This is a useful PR but it starts to mold. Let's give it one more pass and then merge? |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 7 s compile time in total, 7 of them have a recent master baseline. |
| continue; | ||
| auto data = column->getDataAt(row); | ||
| sketch.update(data.data(), data.size(), 1); | ||
| const size_t max_dense_distinct_values = column_low_cardinality->size() / min_dense_dictionary_value_reuse; |
There was a problem hiding this comment.
max_dense_distinct_values is based on column_low_cardinality->size(), so LowCardinality(Nullable(T)) blocks with many NULLs are treated as high-reuse even when every non-NULL value is unique. For example, 90 NULL rows plus 10 distinct strings give N = 100 and dictionary.size() == 12, so this branch still takes countKeys(). The old row-wise build already skips the 90 NULLs, so both paths perform only 10 sketch.updates, but the new one adds a full index-counting pass and a ColumnUInt64 allocation.
Please base the dense cutoff on non-NULL rows for nullable LowCardinality columns (for example size() - getNumberOfDefaultRows()), or keep this shape on the row-wise fallback. A focused nullable low-reuse regression would help keep the cutoff honest.
| /// A filtered column may retain a large dictionary while referencing | ||
| /// only a few entries. Bound the temporary hash map more conservatively | ||
| /// than the dense counter. | ||
| const size_t max_sparse_distinct_values = column_low_cardinality->size() / min_sparse_dictionary_value_reuse; |
There was a problem hiding this comment.
This sparse cutoff has the same Nullable hole as the dense branch above. size() counts NULL rows, but updateSketchRowWise skips them, so a LowCardinality(Nullable(String)) block with, for example, 90 NULLs and 10 distinct non-NULL values in a retained dictionary still gets max_sparse_distinct_values = 10. If the NULLs come first, countTouchedDictionaryIndexes walks the whole block, allocates the hash map, and only breaks on the last row, even though the old row-wise path would have done just 10 sketch.updates. That regresses the same low-reuse shape this fallback is supposed to protect. Please derive the sparse cutoff from the non-NULL row count for nullable LowCardinality columns as well.
|
This PR somehow blew up. Can we merge a minimal version with max. +20 LOC C++ changes (please see my earlier comment about the weird path of small dictionaries) + a single .xml performance test + a single .sql test? We don't need to overthink this PR - count-min statistics are and will not be the default. |
|
This PR is generally useful but stuck and less of a priority at the moment. Allow me to close it to get it off the radar for now. We can re-open at some point (but then it would need more activity). |
Found during benchmarking
ColumnStatistics.CountMinSketchdoes currently not have a optimized code path forLowCardinalitycolumns. This PR adds such code path.Related:
StatisticsUniqhas an optimized code path too.StatisticsTDigestdoes not.StatisticsMinMaxcallsColumnLowCardinality::getExtemes()which materializes the full indexed column.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
CountMinSketch based column statistics are now more efficiently computed on LowCardinality columns.
Workflow [PR]
Sync PR [sync-upstream/pr/109227]