Skip to content

Commit e816611

Browse files
authored
Merge pull request #3644 from ClickHouse/primary_indexes_align_live_queries
Revert making some of the queries runnable.
2 parents e48666f + 11687c1 commit e816611

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

docs/managing-data/core-concepts/primary-indexes.md

+5-10
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Each [data part](/parts) in the table has its own primary index. We can inspect
7272

7373
The following query lists the number of entries in the primary index for each data part of our example table:
7474

75-
```sql runnable=true
75+
```sql
7676
SELECT
7777
part_name,
7878
max(mark_number) as entries
@@ -82,7 +82,6 @@ GROUP BY part_name;
8282

8383

8484
```txt
85-
Static result for the query above from April 2025
8685
┌─part_name─┬─entries─┐
8786
1. │ all_2_2_0 │ 914 │
8887
2. │ all_1_1_0 │ 1343 │
@@ -92,7 +91,7 @@ Static result for the query above from April 2025
9291

9392
This query shows the first 10 entries from the primary index of one of the current data parts. Note that these parts are continuously [merged](/merges) in the background into larger parts:
9493

95-
```sql runnable=true
94+
```sql
9695
SELECT
9796
mark_number + 1 as entry,
9897
town,
@@ -105,7 +104,6 @@ LIMIT 10;
105104

106105

107106
```txt
108-
Static result for the query above from April 2025
109107
┌─entry─┬─town───────────┬─street───────────┐
110108
1. │ 1 │ ABBOTS LANGLEY │ ABBEY DRIVE │
111109
2. │ 2 │ ABERDARE │ RICHARDS TERRACE │
@@ -121,7 +119,7 @@ Static result for the query above from April 2025
121119
```
122120

123121
Lastly, we use the [EXPLAIN](/sql-reference/statements/explain) clause to see how the primary indexes of all data parts are used to skip granules that can’t possibly contain rows matching the example query’s predicates. These granules are excluded from loading and processing:
124-
```sql runnable=true
122+
```sql
125123
EXPLAIN indexes = 1
126124
SELECT
127125
max(price)
@@ -133,7 +131,6 @@ WHERE
133131

134132

135133
```txt
136-
Static result for the query above from April 2025
137134
┌─explain────────────────────────────────────────────────────────────────────────────────────────────────────┐
138135
1. │ Expression ((Project names + Projection)) │
139136
2. │ Aggregating │
@@ -155,15 +152,14 @@ Static result for the query above from April 2025
155152
Note how row 13 of the EXPLAIN output above shows that only 3 out of 3,609 granules across all data parts were selected by the primary index analysis for processing. The remaining granules were skipped entirely.
156153

157154
We can also observe that most of the data was skipped by simply running the query:
158-
```sql runnable=true
155+
```sql
159156
SELECT max(price)
160157
FROM uk.uk_price_paid_simple
161158
WHERE (town = 'LONDON') AND (street = 'OXFORD STREET');
162159
```
163160

164161

165162
```txt
166-
Static result for the query above from April 2025
167163
┌─max(price)─┐
168164
1. │ 263100000 │ -- 263.10 million
169165
└────────────┘
@@ -173,12 +169,11 @@ Peak memory usage: 13.00 MiB.
173169
```
174170

175171
As shown above, only around 25,000 rows were processed out of approximately 30 million rows in the example table:
176-
```sql runnable=true
172+
```sql
177173
SELECT count() FROM uk.uk_price_paid_simple;
178174
```
179175

180176
```txt
181-
Static result for the query above from April 2025
182177
┌──count()─┐
183178
1. │ 29556244 │ -- 29.56 million
184179
└──────────┘

0 commit comments

Comments
 (0)