---
title: "Introducing the query condition cache"
description: "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."
url: "https://swe.quest/articles/introducing-the-query-condition-cache-8138f22b787679a8"
canonical: "https://clickhouse.com/blog/introducing-the-clickhouse-query-condition-cache"
source: "ClickHouse"
published: "2025-03-28"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 11
tags: ["caching","query-engines","analytics","performance"]
---

# Introducing the query condition cache

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2025-03-28, 11 min read, Deep dive. Original: [https://clickhouse.com/blog/introducing-the-clickhouse-query-condition-cache](https://clickhouse.com/blog/introducing-the-clickhouse-query-condition-cache)

## Summary

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. On 100 million Bluesky JSON events, a selective LIKE filter that the primary index can't prune dropped from 0.53 s scanning ~99M rows to 0.037 s scanning ~2M rows on a cache hit. Because the cache is keyed on the predicate rather than the full query, different queries sharing the same filter (e.g. grouping by language or hour) also benefit. At one bit per granule, the default 100 MB cache covers ~839 million granule entries; it is off by default while edge cases like FINAL on ReplacingMergeTree are hardened.

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)
- [Query engines](https://swe.quest/tags/query-engines.md) (Data & databases)
- [Analytics & OLAP](https://swe.quest/tags/analytics.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))
- columnar databases ([easy posts on Databases](https://swe.quest/tags/databases.md?difficulty=easy))
- ClickHouse MergeTree granules ([easy posts on Analytics & OLAP](https://swe.quest/tags/analytics.md?difficulty=easy))

## Keywords

ClickHouse, query condition cache, MergeTree, Bluesky, JSON type, ClickHouse 25.3

## Related posts

- [Introducing the ClickHouse Query Cache](https://swe.quest/articles/introducing-the-clickhouse-query-cache-4c8e8c32056d93c8.md): ClickHouse · 2023-02-09 · Medium · 9 min read · Caching, Analytics & OLAP, Databases, Performance engineering
  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 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 Newsletter May 2022: Explain Statement – Query Optimization](https://swe.quest/articles/clickhouse-newsletter-may-2022-explain-statement-query-optimization-a636e0c953208fbf.md): ClickHouse · 2022-05-09 · Medium · 8 min read · Query engines, Analytics & OLAP, Performance engineering, SQL
  ClickHouse's May 2022 newsletter centers on using EXPLAIN for query optimization.
- [ClickHouse Release 25.2](https://swe.quest/articles/clickhouse-release-25-2-70e1ceccfb09d252.md): ClickHouse · 2025-03-07 · Medium · 8 min read · Analytics & OLAP, Query engines, Performance engineering, Data structures
  ClickHouse 25.2 ships 12 features, 15 performance optimizations and 72 bug fixes.
- [ClickHouse Release 25.3](https://swe.quest/articles/clickhouse-release-25-3-9135d1897f13fbb5.md): ClickHouse · 2025-03-27 · Medium · 8 min read · Analytics & OLAP, Query engines, Caching, Distributed databases
  ClickHouse 25.3 adds query support for AWS Glue and Unity lakehouse catalogs and declares the columnar JSON type, along with the Variant and Dynamic types it is built on, production-ready.

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)
