Pre-Caching ClickHouse Metadata to the Memory
This section applies to MRS 3.3.1-LTS or later.
Scenario
If there are a large number of service tables holding a large amount of data, loading metadata during rolling restart is time-consuming. You can use RocksDB to pre-cache the metadata to the memory to accelerate metadata loading.
Enabling Metadata Pre-Caching
You can set use_metadata_cache to 1 or true to cache metadata to the memory through RocksDB.
- Use the ClickHouse client to connect to the ClickHouse server by referring to ClickHouse Client Practices.
- Configure metadata pre-caching.
- Enable metadata pre-caching for historical tables.
ALTER TABLE <table name> MODIFY SETTING use_metadata_cache=1;
Or
ALTER TABLE <table name> MODIFY SETTING use_metadata_cache=true;
- Enable metadata pre-caching when you create a table.
(
`x` UInt32,
`y` UInt32,
`z` UInt32,
`t` UInt32
)
ENGINE = MergeTree
PARTITION BY x % 10
ORDER BY (x, y)
SETTINGS index_granularity = 8192, use_metadata_cache = 1
or
CREATE TABLE <table name>
(
`x` UInt32,
`y` UInt32,
`z` UInt32,
`t` UInt32
)
ENGINE = MergeTree
PARTITION BY x % 10
ORDER BY (x, y)
SETTINGS index_granularity = 8192, use_metadata_cache = true
- Enable metadata pre-caching for historical tables.
Parameter Tuning
Metadata pre-caching can be optimized as follows:
Log in to FusionInsight Manager, choose Cluster > Services > ClickHouse, click Configurations and then All Configurations, and modify the following parameters:
Parameter |
Value |
Description |
---|---|---|
merge_tree_metadata_cache.continue_if_corrupted |
true |
If the local RocksDB directory fails to be read, false indicates that you can exit the process, and true indicates that dirty data is cleared. |
merge_tree_metadata_cache.lru_cache_size |
1GB |
Size of the LRU in the RocksDB instance used to cache part metadata |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot