statistics: avoid stats meta full load after table analysis (#57756)#61732
Conversation
|
@0xPoe This PR has conflicts, I have hold it. |
This change modifies the UpdateStatsCache method across multiple files to accept a CacheUpdate struct, which encapsulates updated and deleted tables along with options for cache updates. This refactor improves the clarity and flexibility of cache updates, allowing for better management of cache state during statistics updates. Signed-off-by: 0xPoe <techregister@pm.me>
1fb4819 to
40f961f
Compare
…cache This update modifies the benchmark tests in bench_test.go to utilize the CacheUpdate struct for the UpdateStatsCache method, enhancing consistency and clarity in cache update operations during performance testing. Signed-off-by: 0xPoe <techregister@pm.me>
This change updates the UpdateStatsCache method in update.go to use the statsutil package instead of the util package, ensuring consistency with recent refactors and improving code clarity. Signed-off-by: 0xPoe <techregister@pm.me>
This update modifies the AnalyzeExec's Next method to collect and pass table and partition IDs to the statsHandle.Update method, improving the handling of statistics for partitioned tables. Signed-off-by: 0xPoe <techregister@pm.me>
This commit updates the shard count in the go_test configuration from 13 to 14 for improved test distribution. Additionally, a new test function, TestStatsCacheProcess, is introduced to validate the behavior of the statistics cache during table analysis and updates, ensuring accurate version tracking and cache state management. Signed-off-by: 0xPoe <techregister@pm.me>
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the statistics cache update mechanism to avoid performing a full cache reload after table analysis by updating only the affected tables. Key changes include:
- Introduction of the CacheUpdate and UpdateOptions types to encapsulate cache updates.
- New signatures for Update and UpdateStatsCache methods to allow selective updates via table and partition IDs.
- Updates to various modules (storage, cache, executor, and tests) to support the new update mechanism.
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/statistics/handle/util/interfaces.go | Defines CacheUpdate and UpdateOptions and updates interface signatures for cache updates. |
| pkg/statistics/handle/storage/update.go | Replaces full cache update calls with the new CacheUpdate mechanism. |
| pkg/statistics/handle/storage/stats_read_writer.go | Uses CacheUpdate in updating stats cache after extended statistics reload. |
| pkg/statistics/handle/storage/read.go | Applies CacheUpdate when updating table statistics after histogram loads. |
| pkg/statistics/handle/handletest/statstest/stats_test.go | Adds tests to verify cache behavior and version management with selective updates. |
| pkg/statistics/handle/handletest/statstest/BUILD.bazel | Minor change adjusting test shard count. |
| pkg/statistics/handle/handle_hist.go | Updates cache update call to use the CacheUpdate struct. |
| pkg/statistics/handle/handle.go | Applies the new CacheUpdate approach when updating partition stats. |
| pkg/statistics/handle/cache/statscacheinner.go | Changes Update function signature to accept the skipMoveForward flag. |
| pkg/statistics/handle/cache/statscache.go | Refactors UpdateStatsCache to use CacheUpdate and conditionally control version updates. |
| pkg/statistics/handle/cache/bench_test.go | Modifies benchmarks to use the new CacheUpdate API. |
| pkg/executor/analyze.go | Enhances update calls by passing table and partition IDs to optimize cache reloads. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: 0xPoe, elsa0520, winoros The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/unhold |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## release-7.5 #61732 +/- ##
================================================
Coverage ? 72.2053%
================================================
Files ? 1417
Lines ? 414310
Branches ? 0
================================================
Hits ? 299154
Misses ? 95148
Partials ? 20008
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This is an automated cherry-pick of #57756
What problem does this PR solve?
Issue Number: close #57631
Problem Summary:
See more at #57631 (comment)
We need to support updating the stats of only a few tables within the update function. This will help reduce the function's duration after the table analysis is completed.
The analysis duration is stable:
What changed and how does it work?
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.