Repository navigation
Conversation
|
What happens if one part with a materialized index and one part without it are merged? |
For a part with a materialized index, the |
|
This is out of scope for this PR, but I wonder if an additional optimization is possible: if a part is not pruned, and the KeyCondition cannot be false for the whole part, can we disable analysis for that index in that part? For example:
We are sure before reading the part that every granule will match this condition, because all values must be in the range 123..456, which all satisfies >100. So it would be nice to save the work of comparing every mark within the part when the solution is trivial. (This applies more generally too: we can also skip reading the |
|
Workflow [PR], commit [10790d8] Summary: ❌
|
|
Based on the output of EDIT: actually the partition-key-based MinMax check also happens before checking the partition key, huh. Makes we wonder if this could be merged with that and if both could be configurable as before or after partition pruning in cases where the partition filter is very selective (e.g. |
5f00b48 to
73a4c4e
Compare
At pruning time, all three are simple in-memory comparisons with similar costs. The current order follows existing pattern. |
73a4c4e to
2b0d83b
Compare
|
The CI failure seems unrelated to my changes. |
| MergeTreeIndexSubstreams getSubstreams() const override { return {{MergeTreeIndexSubstream::Type::Regular, "", ".idx2"}}; } | ||
| MergeTreeIndexFormat getDeserializedFormat(const MergeTreeDataPartChecksums & checksums, const std::string & path_prefix) const override; /// NOLINT | ||
|
|
||
| bool supportsPartLevelAggregation() const override { return true; } |
There was a problem hiding this comment.
Two questions:
-
In the current implementation, is there a reason why part-level indexes are limited to min-max indexes? I think we can merge at least also SET indexes. Merging bloom filter indexes isn't feasible (without saturating the index, i.e. making it useless)
-
That brings me to the more important point. Please don't beat me for saying that but the merging mechanism is a crutch. It optimizes for the wrong goal. Its advantage is that it can re-use existing metadata at part write time to save some CPU. The disadvantage is that it is limited to min-max (and set) indexes. Imagine a another mechanism where the part-level index is built from scratch. Advantage: we could use arbitrary data structures as metadata Disadvantage: slightly longer construction time but that's fine in ClickHouse. The thing is that just that already exists: https://clickhouse.com/docs/engines/table-engines/mergetree-family/mergetree#column-statistics, there is even a min-max type of statistics. I would suggest that we rather use this. We plan to enable the statistics by default for numeric types soon, then it would be more ubiquitous than today.
There was a problem hiding this comment.
This PR has another advantage which I forgot: Min max indexes can be build on top of arbitrary expressions, statistics only on columns. But that's not a great loss, IMHO.
|
@hanfei1991 FYI |
|
@rschu1ze Thanks for your valuable feedback! I agree that I'm considering introducing a new abstraction layer called ZoneMap to unify ZoneMap data sources:
Separation of concerns:
This aligns with how other OLAP systems handle this. The ZoneMap abstraction layer is also extensible - in the future, it could integrate additional metadata such as null counts or other metrics. Does this direction make sense? I'd appreciate your suggestions. |
|
We briefly discussed this proposal with hanfei1991@. I'd agree that re-using the existing Statistics code looks preferable. The biggest missing part for now is that we don't apply statistics to parts pruning. So, IMO:
|
|
@nickitat Thanks for your reply. I understand now that reusing the statistics data is enough. I will continue working on implementing statistics application for parts pruning. |
|
By the way, using statistics for pruning as @nickitat proposed introduces an interesting requirement: Statistic must not "lie" about the data, otherwise we'll prune too much and get wrong results. This is different from join reordering where lying statistics are okay. |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Add part-level aggregation for MergeTree minmax skip indexes to enable part pruning before granule-level filtering, as discussed in #65413 and #64210.
Documentation entry for user-facing changes
Details
allow_experimental_skip_index_part_aggregationsetting to enable transparent part-level index aggregation;.pidxfiles during data insertion, merge operations, and MATERIALIZE INDEX;.idxfiles for backward compatibility;