Skip to content

Commit 6fbd4a7

Browse files
committed
Merge branch 'main' of https://github.com/ClickHouse/clickhouse-docs into dhtclk-patch3
2 parents ef474cf + 56d5ed3 commit 6fbd4a7

File tree

270 files changed

+5677
-2648
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

270 files changed

+5677
-2648
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
* @ClickHouse/docs
2-
/docs/integrations/data-ingestion/clickpipes/ @ClickHouse/clickpipes @ClickHouse/docs
32
/docs/integrations/ @ClickHouse/integrations-ecosystem @ClickHouse/docs
3+
/docs/integrations/data-ingestion/clickpipes/ @ClickHouse/clickpipes @ClickHouse/docs

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ Please assign any pull request (PR) against an issue; this helps the docs team t
134134
135135
Check out the GitHub docs for a refresher on [how to create a pull request](https://docs.github.com/en/desktop/working-with-your-remote-repository-on-github-or-github-enterprise/creating-an-issue-or-pull-request-from-github-desktop).
136136
137-
### Style guidelines
137+
### Style and contribution guidelines
138138
139-
For documentation style guidelines, see ["Style guide"](/contribute/style-guide.md).
139+
For documentation style guidelines, see ["Style guide"](/contribute/style-guide.md).
140140
141141
To check spelling and markdown is correct locally run:
142142
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
receivers:
2+
filelog:
3+
include:
4+
- /opt/data/logs/access-unstructured.log
5+
start_at: beginning
6+
operators:
7+
- type: regex_parser
8+
regex: '^(?P<ip>[\d.]+)\s+-\s+-\s+\[(?P<timestamp>[^\]]+)\]\s+"(?P<method>[A-Z]+)\s+(?P<url>[^\s]+)\s+HTTP/[^\s]+"\s+(?P<status>\d+)\s+(?P<size>\d+)\s+"(?P<referrer>[^"]*)"\s+"(?P<user_agent>[^"]*)"'
9+
timestamp:
10+
parse_from: attributes.timestamp
11+
layout: '%d/%b/%Y:%H:%M:%S %z'
12+
#22/Jan/2019:03:56:14 +0330
13+
processors:
14+
batch:
15+
timeout: 1s
16+
send_batch_size: 100
17+
memory_limiter:
18+
check_interval: 1s
19+
limit_mib: 2048
20+
spike_limit_mib: 256
21+
exporters:
22+
# HTTP setup
23+
otlphttp/hdx:
24+
endpoint: 'http://localhost:4318'
25+
headers:
26+
authorization: <YOUR_INGESTION_API_KEY>
27+
compression: gzip
28+
29+
# gRPC setup (alternative)
30+
otlp/hdx:
31+
endpoint: 'localhost:4317'
32+
headers:
33+
authorization: <YOUR_API_INGESTION_KEY>
34+
compression: gzip
35+
service:
36+
telemetry:
37+
metrics:
38+
address: 0.0.0.0:9888 # Modified as 2 collectors running on same host
39+
pipelines:
40+
logs:
41+
receivers: [filelog]
42+
processors: [batch]
43+
exporters: [otlphttp/hdx]

contribute/style-guide.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,73 @@ SELECT * FROM system.contributors;
112112
\```
113113
```
114114

115+
Note: in the snippet above `\` is used only for formatting purposes in this guide.
116+
You should not include it when you write markdown.
117+
115118
Code blocks:
116119
- Should always have a language defined immediately next to the opening 3
117120
backticks, without any space.
118121
- Have a title (optional) such as 'Query' or 'Response'
119122
- Use language `response` if it is for the result of a query.
120123

124+
#### Importing code from files or URLs
125+
126+
There are a few additional parameters you can include on a code block if you want
127+
to import code.
128+
129+
To import from a file use `file=`:
130+
131+
```text
132+
\```python file=code_snippets/integrations/example.py
133+
Code will be inserted here
134+
\```
135+
```
136+
137+
When `yarn build` is run, the code from the file will be inserted as text into
138+
the code block.
139+
140+
To import from a url use `url=`:
141+
142+
```text
143+
\```python url=https://raw.githubusercontent.com/ClickHouse/clickhouse-connect/refs/heads/main/examples/pandas_examples.py
144+
Code will be inserted here
145+
\```
146+
```
147+
148+
You should commit the code inserted to the snippet as we want people (or LLMs)
149+
reading the markdown to be able to see the code. The advantage of importing code
150+
to snippets this way is that you can test your snippets externally or store them
151+
wherever you want.
152+
153+
If you want to only import a section from a file, surround the section with `docs-start`
154+
and `docs-end` comments, for example:
155+
156+
```python
157+
a = 200
158+
b = 33
159+
#docs-start
160+
if b > a:
161+
print("b is greater than a")
162+
elif a == b:
163+
print("a and b are equal")
164+
else:
165+
print("a is greater than b")
166+
#docs-end
167+
```
168+
169+
Only the code between those comments will be pulled.
170+
171+
If you want to make multiple code snippets from one file then you can use the `snippet` parameter:
172+
173+
```markdown
174+
175+
\```python url=https://raw.githubusercontent.com/ClickHouse/clickhouse-connect/refs/heads/main/examples/pandas_examples.py snippet=1
176+
Code will be inserted here
177+
\```
178+
```
179+
180+
You will then use `docs-start-1`, `docs-end-1` comments for the first snippet, `docs-start-2`, `docs-end-2` for the second snippet and so on.
181+
121182
### Highlighting
122183

123184
You can highlight lines in a code block using the following keywords:

docs/_snippets/_users-and-roles-common.md

Lines changed: 55 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -42,64 +42,73 @@ Create these tables and users to be used in the examples.
4242

4343
#### Creating a sample database, table, and rows {#creating-a-sample-database-table-and-rows}
4444

45-
1. Create a test database
45+
<VerticalStepper headerLevel="h5">
4646

47-
```sql
48-
CREATE DATABASE db1;
49-
```
47+
##### Create a test database {#create-a-test-database}
5048

51-
2. Create a table
49+
```sql
50+
CREATE DATABASE db1;
51+
```
5252

53-
```sql
54-
CREATE TABLE db1.table1 (
55-
id UInt64,
56-
column1 String,
57-
column2 String
58-
)
59-
ENGINE MergeTree
60-
ORDER BY id;
61-
```
53+
##### Create a table {#create-a-table}
6254

63-
3. Populate the table with sample rows
55+
```sql
56+
CREATE TABLE db1.table1 (
57+
id UInt64,
58+
column1 String,
59+
column2 String
60+
)
61+
ENGINE MergeTree
62+
ORDER BY id;
63+
```
6464

65-
```sql
66-
INSERT INTO db1.table1
67-
(id, column1, column2)
68-
VALUES
69-
(1, 'A', 'abc'),
70-
(2, 'A', 'def'),
71-
(3, 'B', 'abc'),
72-
(4, 'B', 'def');
73-
```
65+
##### Populate the table with sample rows {#populate}
7466

75-
4. Verify the table:
67+
```sql
68+
INSERT INTO db1.table1
69+
(id, column1, column2)
70+
VALUES
71+
(1, 'A', 'abc'),
72+
(2, 'A', 'def'),
73+
(3, 'B', 'abc'),
74+
(4, 'B', 'def');
75+
```
7676

77-
```sql
78-
SELECT *
79-
FROM db1.table1
80-
```
77+
##### Verify the table {#verify}
8178

82-
```response
83-
Query id: 475015cc-6f51-4b20-bda2-3c9c41404e49
79+
```sql title="Query"
80+
SELECT *
81+
FROM db1.table1
82+
```
8483

85-
┌─id─┬─column1─┬─column2─┐
86-
│ 1 │ A │ abc │
87-
│ 2 │ A │ def │
88-
│ 3 │ B │ abc │
89-
│ 4 │ B │ def │
90-
└────┴─────────┴─────────┘
91-
```
84+
```response title="Response"
85+
Query id: 475015cc-6f51-4b20-bda2-3c9c41404e49
9286
93-
5. Create a regular user that will be used to demonstrate restrict access to certain columns:
87+
┌─id─┬─column1─┬─column2─┐
88+
│ 1 │ A │ abc │
89+
│ 2 │ A │ def │
90+
│ 3 │ B │ abc │
91+
│ 4 │ B │ def │
92+
└────┴─────────┴─────────┘
93+
```
9494

95-
```sql
96-
CREATE USER column_user IDENTIFIED BY 'password';
97-
```
95+
##### Create `column_user` {#create-a-user-with-restricted-access-to-columns}
9896

99-
6. Create a regular user that will be used to demonstrate restricting access to rows with certain values:
100-
```sql
101-
CREATE USER row_user IDENTIFIED BY 'password';
102-
```
97+
Create a regular user that will be used to demonstrate restrict access to certain columns:
98+
99+
```sql
100+
CREATE USER column_user IDENTIFIED BY 'password';
101+
```
102+
103+
##### Create `row_user` {#create-a-user-with-restricted-access-to-rows-with-certain-values}
104+
105+
Create a regular user that will be used to demonstrate restricting access to rows with certain values:
106+
107+
```sql
108+
CREATE USER row_user IDENTIFIED BY 'password';
109+
```
110+
111+
</VerticalStepper>
103112

104113
#### Creating roles {#creating-roles}
105114

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
| Page | Description |
2+
|--------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|
3+
| [Choosing a Primary Key](/best-practices/choosing-a-primary-key) | How to select primary keys that maximize query performance and minimize storage overhead. |
4+
| [Select Data Types](/best-practices/select-data-types) | Choose optimal data types to reduce memory usage, improve compression, and accelerate queries. |
5+
| [Use Materialized Views](/best-practices/use-materialized-views) | Leverage materialized views to pre-aggregate data and dramatically speed up analytical queries. |
6+
| [Minimize and Optimize JOINs](/best-practices/minimize-optimize-joins) | Best practices for using ClickHouse's `JOIN` capabilities efficiently. |
7+
| [Choosing a Partitioning Key](/best-practices/choosing-a-partitioning-key) | Select partitioning strategies that enable efficient data pruning and faster query execution. |
8+
| [Selecting an Insert Strategy](/best-practices/selecting-an-insert-strategy) | Optimize data ingestion throughput and reduce resource consumption with proper insert patterns. |
9+
| [Data Skipping Indices](/best-practices/use-data-skipping-indices-where-appropriate) | Apply secondary indices strategically to skip irrelevant data blocks and accelerate filtered queries. |
10+
| [Avoid Mutations](/best-practices/avoid-mutations) | Design schemas and workflows that eliminate costly `UPDATE`/`DELETE` operations for better performance. |
11+
| [Avoid OPTIMIZE FINAL](/best-practices/avoid-optimize-final) | Prevent performance bottlenecks by understanding when `OPTIMIZE FINAL` hurts more than it helps. |
12+
| [Use JSON where appropriate](/best-practices/use-json-where-appropriate) | Balance flexibility and performance when working with semi-structured JSON data in ClickHouse. |

docs/best-practices/index.md

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,10 @@ hide_title: true
66
description: 'Landing page for Best Practices section in ClickHouse'
77
---
88

9+
import TableOfContents from '@site/docs/best-practices/_snippets/_table_of_contents.md';
10+
911
# Best Practices in ClickHouse {#best-practices-in-clickhouse}
1012

1113
This section provides the best practices you will want to follow to get the most out of ClickHouse.
1214

13-
| Page | Description |
14-
|----------------------------------------------------------------------|--------------------------------------------------------------------------|
15-
| [Choosing a Primary Key](/best-practices/choosing-a-primary-key) | Guidance on selecting an effective Primary Key in ClickHouse. |
16-
| [Select Data Types](/best-practices/select-data-types) | Recommendations for choosing appropriate data types. |
17-
| [Use Materialized Views](/best-practices/use-materialized-views) | When and how to benefit from materialized views. |
18-
| [Minimize and Optimize JOINs](/best-practices/minimize-optimize-joins)| Best practices for minimizing and optimizing JOIN operations. |
19-
| [Choosing a Partitioning Key](/best-practices/choosing-a-partitioning-key) | How to choose and apply partitioning keys effectively. |
20-
| [Selecting an Insert Strategy](/best-practices/selecting-an-insert-strategy) | Strategies for efficient data insertion in ClickHouse. |
21-
| [Data Skipping Indices](/best-practices/use-data-skipping-indices-where-appropriate) | When to apply data skipping indices for performance gains. |
22-
| [Avoid Mutations](/best-practices/avoid-mutations) | Reasons to avoid mutations and how to design without them. |
23-
| [Avoid OPTIMIZE FINAL](/best-practices/avoid-optimize-final) | Why `OPTIMIZE FINAL` can be costly and how to work around it. |
24-
| [Use JSON where appropriate](/best-practices/use-json-where-appropriate) | Considerations for using JSON columns in ClickHouse. |
15+
<TableOfContents/>

0 commit comments

Comments
 (0)