Skip to content

Commit 435433b

Browse files
committed
Add basic documentation
1 parent 609ba2f commit 435433b

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
slug: /operations/query-cache
3+
sidebar_position: 64
4+
sidebar_label: Query Condition Cache
5+
---
6+
7+
# Query Condition Cache
8+
9+
Many practical workloads expose repeated queries against the same data.
10+
If users are aware of these patterns, they can create primary key indexes, skipping indexes, projections etc., to speed up such queries.
11+
This however requires careful monitoring of the workload and explicit tuning (i.e., physical schema optimization) from a database administrator.
12+
13+
The query condition cache addresses this by remembering which ranges of the data cannot possibly satisfy filter predicates.
14+
For example, if the user runs the query `SELECT * FROM tab WHERE col = 'a'`, ClickHouse will scan column `col` for filter predicate `col = 'a'`.
15+
At the end of the scan, the query condition cache will remember which vertical ranges of table `tab` did not match the predicate.
16+
When the user runs the same query again, ClickHouse will first check the cache and exclude non-matching data ranges from the subsequent scan.
17+
18+
## Configuration Settings and Usage {#configuration-settings-and-usage}
19+
20+
Setting [use_query_cache](/operations/settings/settings#use_query_condition_cache) controls whether a specific query or all queries of the
21+
current session should utilize the query condition cache. For example, the first execution of query
22+
23+
```sql
24+
SELECT col1, col2
25+
FROM table
26+
WHERE col1 = 'x'
27+
SETTINGS use_query_condition_cache = true;
28+
```
29+
30+
will store ranges of the table which do not satisfy the predicate.
31+
Subsequent executions of the same query (also with parameter `use_query_condition_cache = true`) will utilize the query condition cache to scan less data.

0 commit comments

Comments
 (0)