ClickHouse/docs/en/introduction/distinctive-features.md

97 lines
7.8 KiB
Markdown
Raw Normal View History

2020-04-03 13:23:32 +00:00
---
toc_priority: 4
toc_title: Distinctive Features
---
2020-03-20 10:10:48 +00:00
# Distinctive Features of ClickHouse {#distinctive-features-of-clickhouse}
2020-06-19 10:31:21 +00:00
## True Column-Oriented Database Management System {#true-column-oriented-dbms}
2017-04-03 19:49:50 +00:00
In a real column-oriented DBMS, no extra data is stored with the values. Among other things, this means that constant-length values must be supported, to avoid storing their length “number” next to the values. For example, a billion UInt8-type values should consume around 1 GB uncompressed, or this strongly affects the CPU use. It is essential to store data compactly (without any “garbage”) even when uncompressed since the speed of decompression (CPU usage) depends mainly on the volume of uncompressed data.
2017-04-03 19:49:50 +00:00
It is worth noting because there are systems that can store values of different columns separately, but that cant effectively process analytical queries due to their optimization for other scenarios. Examples are HBase, BigTable, Cassandra, and HyperTable. You would get throughput around a hundred thousand rows per second in these systems, but not hundreds of millions of rows per second.
2017-04-03 19:49:50 +00:00
2020-03-20 10:10:48 +00:00
Its also worth noting that ClickHouse is a database management system, not a single database. ClickHouse allows creating tables and databases in runtime, loading data, and running queries without reconfiguring and restarting the server.
2017-04-03 19:49:50 +00:00
2020-03-20 10:10:48 +00:00
## Data Compression {#data-compression}
Some column-oriented DBMSs do not use data compression. However, data compression does play a key role in achieving excellent performance.
In addition to efficient general-purpose compression codecs with different trade-offs between disk space and CPU consumption, ClickHouse provides [specialized codecs](../sql-reference/statements/create/table.md#create-query-specialized-codecs) for specific kinds of data, which allow ClickHouse to compete with and outperform more niche databases, like time-series ones.
2017-04-03 19:49:50 +00:00
2020-03-20 10:10:48 +00:00
## Disk Storage of Data {#disk-storage-of-data}
Keeping data physically sorted by primary key makes it possible to extract data for its specific values or value ranges with low latency, less than a few dozen milliseconds. Some column-oriented DBMSs (such as SAP HANA and Google PowerDrill) can only work in RAM. This approach encourages the allocation of a larger hardware budget than is necessary for real-time analysis.
ClickHouse is designed to work on regular hard drives, which means the cost per GB of data storage is low, but SSD and additional RAM are also fully used if available.
2020-03-20 10:10:48 +00:00
## Parallel Processing on Multiple Cores {#parallel-processing-on-multiple-cores}
2017-04-03 19:49:50 +00:00
2020-03-27 07:45:31 +00:00
Large queries are parallelized naturally, taking all the necessary resources available on the current server.
2017-04-03 19:49:50 +00:00
2020-03-20 10:10:48 +00:00
## Distributed Processing on Multiple Servers {#distributed-processing-on-multiple-servers}
2018-09-06 17:40:13 +00:00
Almost none of the columnar DBMSs mentioned above have support for distributed query processing.
2020-03-27 07:45:31 +00:00
In ClickHouse, data can reside on different shards. Each shard can be a group of replicas used for fault tolerance. All shards are used to run a query in parallel, transparently for the user.
2017-04-03 19:49:50 +00:00
2020-03-20 10:10:48 +00:00
## SQL Support {#sql-support}
ClickHouse supports a [declarative query language based on SQL](../sql-reference/index.md) that is identical to the ANSI SQL standard in [many cases](../sql-reference/ansi.md).
Supported queries include [GROUP BY](../sql-reference/statements/select/group-by.md), [ORDER BY](../sql-reference/statements/select/order-by.md), subqueries in [FROM](../sql-reference/statements/select/from.md), [JOIN](../sql-reference/statements/select/join.md) clause, [IN](../sql-reference/operators/in.md) operator, and scalar subqueries.
Correlated (dependent) subqueries and window functions are not supported at the time of writing but might become available in the future.
## Vector Computation Engine {#vector-engine}
2020-03-27 07:45:31 +00:00
Data is not only stored by columns but is processed by vectors (parts of columns), which allows achieving high CPU efficiency.
2020-03-20 10:10:48 +00:00
## Real-time Data Updates {#real-time-data-updates}
2017-04-03 19:49:50 +00:00
2020-03-27 07:45:31 +00:00
ClickHouse supports tables with a primary key. To quickly perform queries on the range of the primary key, the data is sorted incrementally using the merge tree. Due to this, data can continually be added to the table. No locks are taken when new data is ingested.
2017-04-03 19:49:50 +00:00
## Primary Index {#primary-index}
2020-03-27 07:45:31 +00:00
Having a data physically sorted by primary key makes it possible to extract data for its specific values or value ranges with low latency, less than a few dozen milliseconds.
2017-04-03 19:49:50 +00:00
## Secondary Indexes {#secondary-indexes}
Unlike other database management systems, secondary indexes in ClickHouse does not point to specific rows or row ranges. Instead, they allow the database to know in advance that all rows in some data parts wouldnt match the query filtering conditions and do not read them at all, thus they are called [data skipping indexes](../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-data_skipping-indexes).
2020-03-20 10:10:48 +00:00
## Suitable for Online Queries {#suitable-for-online-queries}
2021-05-27 19:44:11 +00:00
Most OLAP database management systems do not aim for online queries with sub-second latencies. In alternative systems, report building time of tens of seconds or even minutes is often considered acceptable. Sometimes it takes even more which forces to prepare reports offline (in advance or by responding with “come back later”).
In ClickHouse low latency means that queries can be processed without delay and without trying to prepare an answer in advance, right at the same moment while the user interface page is loading. In other words, online.
2020-03-20 10:10:48 +00:00
## Support for Approximated Calculations {#support-for-approximated-calculations}
2018-09-06 17:40:13 +00:00
ClickHouse provides various ways to trade accuracy for performance:
2020-03-20 10:10:48 +00:00
1. Aggregate functions for approximated calculation of the number of distinct values, medians, and quantiles.
2. Running a query based on a part (sample) of data and getting an approximated result. In this case, proportionally less data is retrieved from the disk.
3. Running an aggregation for a limited number of random keys, instead of for all keys. Under certain conditions for key distribution in the data, this provides a reasonably accurate result while using fewer resources.
2017-04-03 19:49:50 +00:00
## Adaptive Join Algorithm {#adaptive-join-algorithm}
ClickHouse adaptively chooses how to [JOIN](../sql-reference/statements/select/join.md) multiple tables, by preferring hash-join algorithm and falling back to the merge-join algorithm if theres more than one large table.
## Data Replication and Data Integrity Support {#data-replication-and-data-integrity-support}
2017-04-03 19:49:50 +00:00
2020-03-27 07:45:31 +00:00
ClickHouse uses asynchronous multi-master replication. After being written to any available replica, all the remaining replicas retrieve their copy in the background. The system maintains identical data on different replicas. Recovery after most failures is performed automatically, or semi-automatically in complex cases.
2017-04-03 19:49:50 +00:00
For more information, see the section [Data replication](../engines/table-engines/mergetree-family/replication.md).
## Role-Based Access Control {#role-based-access-control}
ClickHouse implements user account management using SQL queries and allows for [role-based access control configuration](../operations/access-rights.md) similar to what can be found in ANSI SQL standard and popular relational database management systems.
## Features that Can Be Considered Disadvantages {#clickhouse-features-that-can-be-considered-disadvantages}
1. No full-fledged transactions.
2. Lack of ability to modify or delete already inserted data with a high rate and low latency. There are batch deletes and updates available to clean up or modify data, for example, to comply with [GDPR](https://gdpr-info.eu).
2020-06-19 10:31:21 +00:00
3. The sparse index makes ClickHouse not so efficient for point queries retrieving single rows by their keys.
[Original article](https://clickhouse.com/docs/en/introduction/distinctive-features/) <!--hide-->