v.25.11Improvement

Add two settings: merge tree

Cache table-level statistics, add two settings: merge tree setting refresh_statistics_interval means the interval of refreshing statistics cache, 0 means no cache will be created. Session setting use_statistics_cache means whether to use table-level statistics in a query. Sometimes we want better statistics so we choose to ignore it. #88670 (Han Fei).
Introduces caching of table-level statistics with two new settings: a MergeTree setting refresh_statistics_interval to control the interval for refreshing the statistics cache, and a session setting use_statistics_cache to enable or disable the use of cached statistics during query execution.

Why it matters

The feature improves query performance by caching table-level statistics, reducing overhead from frequent statistics recalculations. It also provides flexibility by allowing users to disable the cache when more accurate or up-to-date statistics are required for specific queries.

How to use it

Set the MergeTree table setting refresh_statistics_interval to a non-zero value (in seconds) to enable periodic refreshing of the cached statistics. Use the session setting use_statistics_cache to true to enable using cached statistics in queries or set it to false to bypass the cache if up-to-date statistics are needed.