ClickHouse Drop Cache
ClickHouse 缓存主要有 [1]:
- mark cache:MergeTree 引擎使用的 marks 文件缓存
- uncompressed cache:MergeTree 引擎使用的未压缩数据缓存,默认关闭
- 操作系统 page cache:非直接使用的文件操作系统页面缓存
还有一些非重要缓存,比如:
- DNS 缓存
- regexp 缓存
- 复杂表达式缓存
- avro 格式数据模型缓存
- 字典数据缓存
- 模型推导缓存
- 文件系统缓存(包括本地和远程文件系统)
- 查询缓存
清空缓存
针对主要缓存可以这样清空:
- mark cache:
DROP MARK CACHE;
- uncompressed cache:
- 一次清空:
DROP UNCOMPRESSED CACHE;
- 会话中关闭:
set use_uncompressed_cache=0;
- 永久关闭:设置 profile level 配置 [2]
- 一次清空:
- 操作系统 page cache:
- 查询临时禁止:
SETTINGS min_bytes_to_use_direct_io=1;
- 会话中关闭:
set min_bytes_to_use_direct_io=1;
- 永久关闭:设置 profile level 配置 [3]
- 查询临时禁止:
其他非重要缓存的清空参考官方文档 [4]:
DROP DNS CACHE;
DROP UNCOMPRESSED CACHE;
DROP COMPILED EXPRESSION CACHE;
DROP QUERY CACHE;
DROP FORMAT SCHEMA CACHE;
DROP FILESYSTEM CACHE [ON CLUSTER cluster_name];
ClickHouse Cache Types
Main cache types:
- mark_cache — Cache of marks used by table engines of the MergeTree family.
- uncompressed_cache — Cache of uncompressed data used by table engines of the MergeTree family.
- Operating system page cache (used indirectly, for files with actual data).
Additional cache types:
- DNS cache.
- Regexp cache.
- Compiled expressions cache.
- Avro format schemas cache.
- Dictionaries data cache.
- Schema inference cache.
- Filesystem cache over S3, Azure, Local and other disks.
- Query cache.
https://presentations.clickhouse.com/meetup60/overview-of-caching.pdf ↩︎
https://clickhouse.com/docs/en/operations/settings/settings#setting-use_uncompressed_cache ↩︎
https://clickhouse.com/docs/en/operations/settings/settings#min_bytes_to_use_direct_io ↩︎
https://clickhouse.com/docs/en/sql-reference/statements/system ↩︎