Repository navigation
Support statistics UniqV2 which internally uses UniqCombined64(12) - #107863
Conversation
|
Workflow [PR], commit [ca4006e] Summary: ❌
AI ReviewSummaryThis PR adds the new PR Metadata
Findings
Tests
Final VerdictStatus: Minimum required actions:
|
|
Let's make a decision regarding #107863 (comment) |
|
Saving ~4KB per column is much better than ~96KB. |
Here is analysis by AI uniqCombined64(12) should be twice of |
Randomized index_granularity changed the granule counts printed by EXPLAIN. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ng it The old branch deserialized a non-null uniqCombined64 state into the start of the nullable wrapper state, ignoring its flag prefix and nested offset, so old parts loaded as a corrupted/NULL statistic after MODIFY COLUMN. Reject the mismatch so the caller ignores and rebuilds the statistic. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
The PR adds a new statistics type. Lots of systematic tests which focus on statistics exist already:
- 02864_statistics_ddl.sql
- 02864_statistics_predicates.sql
- 02864_statistics_create_materialize_drop.sql
Probably more.
The new test 04357_join_order_dp_uniqcombined.sql will eventually test uniq_v2 statistics, but only indirectly and it does not create the coverage which the existing systematic tests would create. By not updating the existing tests, this PR made them stale as well.
Anyways, just saying. Not a blocker, feel free to ignore.
There was a problem hiding this comment.
Good point, we can do it in this PR
| bool is_null = false; | ||
| readBinary(is_null, buf); | ||
|
|
||
| /// `is_null` is whether the state was built through the `Null` wrapper (i.e. a `Nullable` column). |
There was a problem hiding this comment.
StatisticsUniq::deserialize deserves the same code changes to keep things consistent.
There was a problem hiding this comment.
According to the AI review: #107863 (comment)
The uniq is safe here, only uniq_v2 must abort
|
@hanfei1991 Looks good to me in general. So we established that the legacy
|
|
@rschu1ze I wrote a unittest https://gist.github.com/hanfei1991/7503dbdf638b01d1d18ae3bf0b8d78b1 to make graph for uniq and uniqCombined64, the X is number of cardinality, and Y is memory consumption. I didn't make "1% distinctness, 50% distinctness and 99% distinctness" because the memory consumption is only decided by the number of distinct value of the column.
It's not true, for insert (1000 rows per insert), uniq_v2 is faster (See the description of this PR). for select, uniq is faster. I don't know why yet. Need more investigation |
Thanks. Btw., I just learned by looking at the code that |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 183/209 (87.56%) · Uncovered code |
51819a1
Support statistics UniqV2 which internally uses UniqCombined64(12)


This is a follow-up to #95474
New Statistics UniqCombined(12) uses less memory than uniq, and faster on insert
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Support statistics
UniqCombined(12)as a lightweight alternative of statistics uniqVersion info
26.7.1.957(included in26.7and later)