Does the copr-cache-hit_ratio displayed in the execution plan refer to the block cache hit rate in RocksDB?

This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 在执行计划中会显示copr-cache-hit_ratio 是指rocksdb 中的block cache 命中率吗?

| username: watermelon_cn

In the execution plan, does copr-cache-hit_ratio refer to the block cache hit rate in RocksDB?

| username: Raymond | Original post link

No, this is the coprocessor cache for pushdown computation results.

It caches some computation results on the TiDB side. You can try
select count(*) from xxx;
With the coprocessor cache enabled and the table unchanged, the second execution is much faster.

| username: Jellybean | Original post link

Is this mainly for caching memTable and immutable Table?

| username: ljluestc | Original post link

No, the copr-cache-hit_ratio shown in the TiDB execution plan does not refer to the block cache hit rate in RocksDB.

The copr-cache-hit_ratio specifically indicates the hit rate of the coprocessor cache in TiDB. The coprocessor cache is a query result cache used by TiDB to store intermediate results of certain queries. It helps improve query performance by avoiding redundant computations for the same query.

When executing a query, TiDB checks whether the result is already cached in the coprocessor cache. If the result is found in the cache, it is returned directly, resulting in a cache hit. If the result is not in the cache, the query is executed, and the result is stored in the cache for future use, resulting in a cache miss.

The copr-cache-hit_ratio in the execution plan provides information about the effectiveness of the coprocessor cache. It represents the ratio of cache hits to the total number of cache accesses. A higher copr-cache-hit_ratio indicates a higher cache hit rate, meaning a significant portion of queries are benefiting from the cache and avoiding the need for recomputation.

On the other hand, the block cache hit rate in RocksDB refers to the efficiency of the internal block cache of the storage engine. RocksDB uses a block cache to keep frequently accessed data blocks in memory, reducing disk I/O. It is a caching mechanism independent of the coprocessor cache in TiDB.

The two caches serve different purposes and operate at different levels within the TiDB architecture. The copr-cache-hit_ratio in the execution plan specifically relates to the coprocessor cache in TiDB, not the block cache in RocksDB.

| username: redgame | Original post link

There are gains, and it also explained our doubts.