-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: Maintain incremental analyze result #83
Open
Little-Wallace
wants to merge
1
commit into
tikv:master
Choose a base branch
from
Little-Wallace:incremental-analyze
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# RFC: Incremental analyze table | ||
|
||
|
||
## Summary | ||
|
||
This proposal introduce a method to store some result of analyze request from TiDB in TiKV Storage, so that we do not calculate the whole table when we run `analyze table` next time. | ||
|
||
## Motivation | ||
|
||
The initial motivation was to reduce the impact of `analyze table` on the cluster. And then I found that most of the calculations are not needed. | ||
|
||
- In produce environment, most of regions will not be update in a long time. | ||
- The analyze request will cost a lot of CPU resource but the result data of it is very small (In most cases, no more than 0.1% of the total data). | ||
- We can easily know whether the data of a certain region has been changed. | ||
|
||
So we can cache the data in TiKV, which is the result of analyze. | ||
|
||
## Detailed design | ||
|
||
```protobuf | ||
message StatisticCache { | ||
bytes data = 1; | ||
uint64 applied_index = 2; | ||
} | ||
|
||
message RaftSnapshotData { | ||
metapb.Region region = 1; | ||
uint64 file_size = 2; | ||
repeated KeyValue data = 3; | ||
uint64 version = 4; | ||
SnapshotMeta meta = 5; | ||
StatisticCache statistic_cache = 6; | ||
} | ||
``` | ||
|
||
* When a TiKV receives an analyze request it will check the cache and applied index of this region. If the cache data exists and `applied_index` of the cache equals to the current `applied_index` of this region, it means that the region has never write any user data or split. | ||
* This data will be store by raft protocol. So it will also be send to a new peer when the member configure of raft members changes. | ||
|
||
## Future Works | ||
|
||
The current region-size of TiKV is usually set to '100MB'. If this size increases to be larger in the future, we may need to maintain the analyze results for each sub-range in a region. | ||
|
||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if any member changes, this cache will be invalied?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Member changes? Do you mean that TiKV add one peer for this region?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/member changes/member changed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conf change would not make cache invalid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will try some trick method to avoid some conf change(include member changed or leader transfer) making the cache invalid.