Repository navigation
Conversation
Contributor
Author
|
@hanfei1991 Would you mind taking a look? Thanks. |
Member
Member
Contributor
Author
@alexey-milovidov Sorry for the late reply. I looked at the current implementation, and it already covers what this PR was aiming for: column statistics are loaded on demand, only for the columns that are actually needed. I'll close this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When loading a part's statistics, the part currently loads statistics for every column via
getEstimates, even when only a few columns are needed. On wide tables this performs a lot of pointless deserialization.Related: #104691
This change makes per-part statistics load lazily, only for the requested columns:
IMergeTreeDataPart::getEstimatesnow takes the set of requested columns, loads only the missing ones, and caches the result per column. A deterministic miss (no statistics declared, file absent, or corrupted) is recorded as anulloptentry so the column is not re-probed on every query.StatisticsPartPrunerexposesgetCandidateColumnsandfilterPartsByStatisticspasses them togetEstimates.system.parts_columnsdiscovers which columns have statistics via the newgetColumnsWithStatisticsand loads only those.A new
LoadedStatisticsColumnsprofile event counts the per-column statistics that are actually deserialized.The performance test measures a 100-column wide table with 50 parts and a query filtering on 3 columns; part pruning loads 150 columns instead of 5000.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Part-level column statistics are now loaded lazily, only for the columns that are actually needed, reducing statistics deserialization on wide tables.