Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: Tiflash 是否增加缓存机制,类似kv的算子下推缓存,下次命中直接返回
TiFlash itself is used for analytical scenarios and has a large number of repetitive identical SQL query operations, especially in BI scenarios where n users access the same page and perform n queries. Can this query be cached and returned directly?
My understanding is that all queries are received by the TiDB server. If it is the same query, after the first query retrieves results from TiFlash, the results will be stored in the TiDB server’s membuffer. When the query is executed again, it should be able to directly fetch the results from the membuffer.
After watching the course Core Principles and Architecture of TiDB Database [TiDB v6], it seems that the video does not mention any functionality for caching query results between TiFlash and TiDB.
The cache in TiKV is actually the region cache, which stores metadata and SQL result information. TiFlash indeed hasn’t implemented something similar yet.
The TiDB server has a coprocess cache that caches the results of push-down operators from TiKV, which is suitable for small tables and data that doesn’t change much. You need to consider memory and data changes that cause invalidation. In TiFlash, the tables are generally larger and likely to change more frequently, so it seems less suitable for caching results.
Additionally, I just reviewed TiDB’s cache and checked the official website.
I searched for the keyword “tiflash cache” and actually found one.
It seems like this thing should be used by tiflash. However, there is only this related entry in the documentation, and it’s from version 4.0.9.
Personally, I think if you’re not too particular, the cache in the membuffer of the tidb server should be sufficient.
You all have studied this very thoroughly. TiFlash basically uses statistics, and a single row change makes it really unsuitable for caching.
The use case of TiFlash is indeed not related to caching. You can refer to how Oracle converts tables to columnar format and uses appropriate compression algorithms to store them in memory, accelerating analytical queries.
This topic was automatically closed 60 days after the last reply. No new replies are allowed.