feat(query): refresh TopN statistics on append - #20091
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0e098ba9f4
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
0e098ba to
6064b76
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
a9d49cd to
ef82699
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ef82699cc7
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
ef82699 to
24e9fb2
Compare
…eshness # Conflicts: # src/query/storages/fuse/src/fuse_table.rs # src/query/storages/fuse/src/io/write/block_statistics_writer.rs # src/query/storages/fuse/src/io/write/stream/block_builder.rs # src/query/storages/fuse/src/operations/analyze/analyze_ndv_meta.rs # src/query/storages/fuse/src/operations/analyze/analyze_state_sink.rs # src/query/storages/fuse/src/operations/analyze/collect_ndv_source.rs # src/query/storages/fuse/src/operations/commit.rs # src/query/storages/fuse/src/operations/common/processors/sink_commit.rs # src/query/storages/fuse/src/operations/common/processors/transform_mutation_aggregator.rs # tests/sqllogictests/suites/base/09_fuse_engine/09_0053_analyze_top_n.test
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 01acc8535c
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 49905f7d45
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
…eshness # Conflicts: # src/query/storages/fuse/src/operations/commit.rs
|
@zhyass please help review. |
|
mutation will affect the statistics |
There was a problem hiding this comment.
For Block HLL, when a new block is created, a block-level HLL is generated. These block HLLs are stored in a segment-level file with the prefix _hs. This way, when analyzing the table, we only need to read and aggregate these statistics files.
For TOPN, the table statistics file is updated whenever a write occurs. Which is somewhat different from the previous approach.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 25b0715d00
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 34ff36e058
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…eshness # Conflicts: # src/query/storages/fuse/src/operations/commit.rs # src/query/storages/fuse/src/operations/common/processors/sink_commit.rs # src/query/storages/fuse/src/operations/common/processors/transform_mutation_aggregator.rs
I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/
Summary
analyze_top_n_columnsand setanalyze_top_n_size > 0to enable collection for selected columns. If TopN options are disabled or cannot be safely refreshed, the optimizer falls back to the existing statistics behavior until a fullANALYZE.column_top_n, commit meta aggregates it, and snapshot statistics are written together with the new snapshot.LARGE_STRING_BYTES_THRESHOLDso one abnormal string value does not drop the whole TopN column.Implementation
ColumnTopNcarry its own capacity, which avoids passingtop_n_sizethrough every merge/add call.BlockTopNalongside HLL.TableSnapshotStatisticsonly when the existing snapshot statistics match the current snapshot row count and predecessor snapshot id.Tests
Type of change
This change is