-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ensure no page switching + add core concepts
- Loading branch information
1 parent
8c1a449
commit 0cbbd2c
Showing
11 changed files
with
166 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
slug: /en/integrations/mysql | ||
sidebar_label: MySQL | ||
title: MySQL | ||
hide_title: true | ||
--- | ||
|
||
import MySQL from '@site/docs/en/integrations/data-ingestion/dbms/mysql/index.md'; | ||
|
||
<MySQL/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
slug: /en/managing-data/delete_mutations | ||
sidebar_label: Delete Mutations | ||
title: Delete Mutations | ||
hide_title: false | ||
--- | ||
|
||
Delete mutations refers to `ALTER` queries that manipulate table data through delete. Most notably they are queries like `ALTER TABLE DELETE`, etc. Performing such queries will produce new mutated versions of the data parts. This means that such statements would trigger a rewrite of whole data parts for all data that was inserted before the mutation, translating to a large amount of write requests. | ||
|
||
:::info | ||
For deletes, you can avoid these large amounts of write requests by using specialised table engines like [ReplacingMergeTree](/docs/en/guides/replacing-merge-tree) or [CollapsingMergeTree](/docs/en/engines/table-engines/mergetree-family/collapsingmergetree) instead of the default MergeTree table engine. | ||
::: | ||
|
||
import DeleteMutations from '@site/docs/en/sql-reference/statements/alter/delete.md'; | ||
|
||
<DeleteMutations/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
slug: /en/managing-data/drop_partition | ||
sidebar_label: Drop Partition | ||
title: Dropping Partitions | ||
hide_title: false | ||
--- | ||
|
||
## Background | ||
|
||
Partitioning is specified on a table when it is initially defined via the `PARTITION BY` clause. This clause can contain a SQL expression on any columns, the results of which will define which partition a row is sent to. | ||
|
||
The data parts are logically associated with each partition on disk and can be queried in isolation. For the example below, we partition the `posts` table by year using the expression `toYear(CreationDate)`. As rows are inserted into ClickHouse, this expression will be evaluated against each row and routed to the resulting partition if it exists (if the row is the first for a year, the partition will be created). | ||
|
||
```sql | ||
CREATE TABLE posts | ||
( | ||
`Id` Int32 CODEC(Delta(4), ZSTD(1)), | ||
`PostTypeId` Enum8('Question' = 1, 'Answer' = 2, 'Wiki' = 3, 'TagWikiExcerpt' = 4, 'TagWiki' = 5, 'ModeratorNomination' = 6, 'WikiPlaceholder' = 7, 'PrivilegeWiki' = 8), | ||
`AcceptedAnswerId` UInt32, | ||
`CreationDate` DateTime64(3, 'UTC'), | ||
... | ||
`ClosedDate` DateTime64(3, 'UTC') | ||
) | ||
ENGINE = MergeTree | ||
ORDER BY (PostTypeId, toDate(CreationDate), CreationDate) | ||
PARTITION BY toYear(CreationDate) | ||
``` | ||
|
||
Read about setting the partition expression in a section [How to set the partition expression](/docs/en/sql-reference/statements/alter/partition/#how-to-set-partition-expression). | ||
|
||
In ClickHouse, users should principally consider partitioning to be a data management feature, not a query optimization technique. By separating data logically based on a key, each partition can be operated on independently e.g. deleted. This allows users to move partitions, and thus subnets, between [storage tiers](/en/integrations/s3#storage-tiers) efficiently on time or [expire data/efficiently delete from the cluster](/en/sql-reference/statements/alter/partition). | ||
|
||
## Drop Partitions | ||
|
||
`ALTER TABLE ... DROP PARTITION` provides a cost-efficient way to drop a whole partition. | ||
|
||
``` sql | ||
ALTER TABLE table_name [ON CLUSTER cluster] DROP PARTITION|PART partition_expr | ||
``` | ||
|
||
This query tags the partition as inactive and deletes data completely, approximately in 10 minutes. The query is replicated – it deletes data on all replicas. | ||
|
||
In example, below we remove posts from 2008 for the earlier table by dropping the associated partition. | ||
|
||
```sql | ||
SELECT DISTINCT partition | ||
FROM system.parts | ||
WHERE `table` = 'posts' | ||
|
||
┌─partition─┐ | ||
│ 2008 │ | ||
│ 2009 │ | ||
│ 2010 │ | ||
│ 2011 │ | ||
│ 2012 │ | ||
│ 2013 │ | ||
│ 2014 │ | ||
│ 2015 │ | ||
│ 2016 │ | ||
│ 2017 │ | ||
│ 2018 │ | ||
│ 2019 │ | ||
│ 2020 │ | ||
│ 2021 │ | ||
│ 2022 │ | ||
│ 2023 │ | ||
│ 2024 │ | ||
└───────────┘ | ||
|
||
17 rows in set. Elapsed: 0.002 sec. | ||
|
||
ALTER TABLE posts | ||
(DROP PARTITION '2008') | ||
|
||
0 rows in set. Elapsed: 0.103 sec. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
slug: /en/managing-data/truncate | ||
sidebar_label: Truncate Table | ||
title: Truncate Table | ||
hide_title: false | ||
--- | ||
|
||
Truncate allows the data in a table or database to be removed, while preserving their existence. This is a lightweight operation which cannot be reversed. | ||
|
||
import Truncate from '@site/docs/en/sql-reference/statements/truncate.md'; | ||
|
||
<Truncate/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
slug: /en/managing-data/update_mutations | ||
sidebar_label: Update Mutations | ||
title: Update Mutations | ||
hide_title: false | ||
--- | ||
|
||
Update mutations refers to `ALTER` queries that manipulate table data through updates. Most notably they are queries like `ALTER TABLE UPDATE`, etc. Performing such queries will produce new mutated versions of the data parts. This means that such statements would trigger a rewrite of whole data parts for all data that was inserted before the mutation, translating to a large amount of write requests. | ||
|
||
:::info | ||
For updates, you can avoid these large amounts of write requests by using specialised table engines like [ReplacingMergeTree](/docs/en/guides/replacing-merge-tree) or [CollapsingMergeTree](/docs/en/engines/table-engines/mergetree-family/collapsingmergetree) instead of the default MergeTree table engine. | ||
::: | ||
|
||
import UpdateMutations from '@site/docs/en/sql-reference/statements/alter/update.md'; | ||
|
||
<UpdateMutations/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
slug: /en/optimize | ||
sidebar_label: Overview | ||
title: Performance and Optimizations | ||
hide_title: false | ||
--- | ||
|
||
This section contains tips and best practices for improving performance with ClickHouse. We recommend users read [Core Concepts](/docs/en/parts) as a precursor to this section, which covers the main concepts required to improve performance, especially [Primary Indices](/docs/en/optimize/sparse-primary-indexes). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters