---
title: "Introducing the ClickHouse Query Cache"
description: "ClickHouse v23.1 adds an experimental query cache that stores results of expensive SELECT queries for a configurable TTL (60 s by default), cutting a 9-second aggregation over 3.1 billion GitHub events to 0.04 s on repeat runs."
url: "https://swe.quest/articles/introducing-the-clickhouse-query-cache-4c8e8c32056d93c8"
canonical: "https://clickhouse.com/blog/introduction-to-the-clickhouse-query-cache-and-design"
source: "ClickHouse"
published: "2023-02-09"
difficulty: "medium"
kind: "Announcement"
reading_minutes: 9
tags: ["caching","analytics","databases","performance"]
---

# Introducing the ClickHouse Query Cache

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2023-02-09, 9 min read, Announcement. Original: [https://clickhouse.com/blog/introduction-to-the-clickhouse-query-cache-and-design](https://clickhouse.com/blog/introduction-to-the-clickhouse-query-cache-and-design)

## Summary

ClickHouse v23.1 adds an experimental query cache that stores results of expensive SELECT queries for a configurable TTL (60 s by default), cutting a 9-second aggregation over 3.1 billion GitHub events to 0.04 s on repeat runs. A walkthrough shows a common pitfall: results larger than the 1 MiB default max\_entry\_size are silently skipped, which trace logs and system.query\_cache reveal. Settings control read/write-only use, minimum query duration or run counts before caching, caching of non-deterministic functions, and sharing entries between users. The cache is deliberately transactionally inconsistent: inserts and merges don't invalidate entries, which avoids MySQL-style scalability problems. Entries are keyed by the query AST rather than its text.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Caching](https://swe.quest/tags/caching.md) (Backend & APIs)
- [Analytics & OLAP](https://swe.quest/tags/analytics.md) (Data & databases)
- [Databases](https://swe.quest/tags/databases.md) (Data & databases)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)

## Prerequisites

- SQL basics ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))
- ClickHouse basics ([easy posts on Analytics & OLAP](https://swe.quest/tags/analytics.md?difficulty=easy))

## Keywords

ClickHouse, query cache, system.query\_cache, MySQL query cache

## Related posts

- [Introducing the query condition cache](https://swe.quest/articles/introducing-the-query-condition-cache-8138f22b787679a8.md): ClickHouse · 2025-03-28 · Medium · 11 min read · Caching, Query engines, Analytics & OLAP, Performance engineering
  ClickHouse 25.3 adds a query condition cache that records, per table, data part and predicate hash, a bit per granule indicating whether any row matched the WHERE condition, so repeated filters can skip non-matching granules.
- [A simple guide to ClickHouse query optimization: part 1](https://swe.quest/articles/a-simple-guide-to-clickhouse-query-optimization-part-1-007f8d8516577455.md): ClickHouse · 2024-12-11 · Medium · 20 min read · Analytics & OLAP, Performance engineering, SQL, Query engines
  Slow ClickHouse queries can be diagnosed with system.query\_log (duration, rows read, memory, CPU, cache metrics) and the EXPLAIN statement, illustrated on the NYC Taxi dataset in the ClickHouse Playground.
- [ClickHouse Release 23.1](https://swe.quest/articles/clickhouse-release-23-1-134a134aa389ba44.md): ClickHouse · 2023-01-30 · Medium · 8 min read · Analytics & OLAP, Search, Caching, SQL, Databases
  ClickHouse 23.1 adds experimental inverted full-text indices as a data-skipping index, parameterized views, and a TTL-based query results cache, alongside 17 features, 17 performance optimisations and 78 bug fixes.
- [Trade secrets: How Coinhall uses ClickHouse to power its blockchain data platform](https://swe.quest/articles/trade-secrets-how-coinhall-uses-clickhouse-to-power-its-blockchain-data-platform-a19f7fb99396fe78.md): ClickHouse · 2024-08-14 · Easy · 5 min read · Analytics & OLAP, Databases, Performance engineering, Cost optimization
  Coinhall, an omnichain trading terminal aggregating swap data from 23 blockchains, moved from BigQuery (about 2-second queries, thousands of dollars per month) to QuestDB and then to self-hosted ClickHouse.
- [How Rokt Achieved Real-time Reporting with ClickHouse](https://swe.quest/articles/how-rokt-achieved-real-time-reporting-with-clickhouse-89f752e157ebd50c.md): ClickHouse · 2022-12-06 · Easy · 4 min read · Analytics & OLAP, Databases, Cost optimization, E-commerce
  Rokt replaced an Elasticsearch-backed reporting layer with ClickHouse.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
