ClickHouse meetup in Minsk

Author: Alexey Milovidov, 2017-06-30.

ClickHouse meetup in Minsk

ClickHouse: Present and Future

What is ClickHouse?

ClickHouse - distributed analytical column-oriented DBMS

Why column-oriented?

How row-oriented systems work:

Why column-oriented?

How column-oriented systems work:

Why ClickHouse?

Nothing ready-made was suitable.

So we made ClickHouse.

«Evolution of Data Structures in Yandex.Metrica»

https://habrahabr.ru/company/yandex/blog/273305/

Metrica 2.0

In Brief

Main Metrica Cluster

* If you want to try ClickHouse, one server is enough.

ClickHouse at Yandex

We managed to make the system relatively user-friendly.

From the very beginning we had detailed documentation.

Within a couple of years, ClickHouse spread to other Yandex departments.

Mail, Market, Direct, Webmaster, AdFox, Infrastructure, Business Analytics...

There are cases when analysts independently installed ClickHouse on virtual machines and successfully used it without any questions.

Open-source

Then we decided — ClickHouse is too good a system for us to keep it to ourselves.

To make it more fun, we need to get people outside hooked on ClickHouse, let them enjoy it. We decided to go open-source.

Open-source

Apache 2.0 license — minimum restrictions.

Goal — maximum product distribution.

We want Yandex's product to be used worldwide.

See "Yandex Opens ClickHouse"

https://habrahabr.ru/company/yandex/blog/303282/

When to Use ClickHouse

Well-structured, cleaned, immutable events.

 

Click stream. Web analytics. Ad networks. RTB. E-commerce.

Online game analytics. Sensor and monitoring data. Telecom data.

Financial transactions. Stock market analytics.

When NOT to Use ClickHouse

OLTP
ClickHouse has no UPDATE and full-fledged transactions.

Key-Value
If you need frequent update queries by key, use another solution.

Blob-store, document oriented
ClickHouse is designed for a large number of fine-grained data.

Over-normalized data
Better to make a wide fact table.

Why is ClickHouse so Fast?

 

— out of desperation.

Yandex.Metrica must work.

Why is ClickHouse so Fast?

Algorithmic optimization.

MergeTree, data locality on disk
— fast range queries.

Example: the uniqCombined function consists of a combination of three different data structures suitable for different cardinality ranges.

Low-level optimization.

Example: vectorized query execution.

Specialization and attention to detail.

Example: we have 17 different GROUP BY algorithms. The best one is chosen for your query.

ClickHouse Adoption

Hundreds of companies in Russia and nearby
Yandex, Mail.ru, Rambler, SKB Kontur…

Dozens of companies in Europe, USA, China
Cloudflare, Wikimedia, Lifestreet, Vertamedia, Carto…

CloudFlare

How do we analyze over O(100B) DNS requests daily.

"ClickHouse enables us and our customers to explore the the dataset in real time to get operational insights. Due to many of the optimizations built into ClickHouse we are able to store the data for a long time allowing us to look events is perspective and at historical trends."

Wikimedia.org

"clickhouse is a columnar datastore that we are using as an aid to run complex SQL queries on the edit data "lake" that we have as a result of the edit reconstruction project. It is similar to Druid but faster for complex queries."

Unusual ClickHouse Use Cases

Search engine and analytics for Bitcoin transactions:
https://blockchair.com/

"Pretty large tables are running, only one server is used and everything works very quickly — with any filters and sorting, everything is almost instantaneous."

Bioinformatics - evolutionary genetics:
https://github.com/msestak/FindOrigin

"We are exploring evolution of novel genes in genomes because if seems that genomes are far from being static as previously believed and what actually happens is that new genes are constantly being added and old genes are lost."

LHCb experiment at LHC:
https://www.yandex.com/company/press_center/press_releases/2012/2012-04-10/

Independent Benchmarks

ClickHouse vs. Spark & MariaDB Column Store

https://www.percona.com/blog/2017/02/13/clickhouse-new-opensource-columnar-database/

Independent Benchmarks

ClickHouse vs. Redshift

https://www.altinity.com/blog/2017/6/20/clickhouse-vs-redshift

Interfaces

HTTP REST

clickhouse-client

JDBC (production), ODBC (beta)

 

Python, PHP, Perl, Go,
Node.js, Ruby, C++, .NET, Scala, R, Julia, Rust

Integrations with Data Visualization Systems

Tabix (tabix.io) — developed specifically for ClickHouse.

And more:

Grafana, Redash, Apache Zeppelin,
Superset, Power BI…

What's New in ClickHouse

Usability and SQL Compatibility

Session support in HTTP interface:

curl 'http://host:port/?session_id=123&session_timeout=60' \
-d 'CREATE TEMPORARY TABLE t'

Table aliases
Qualified column names in queries:

SELECT t.column FROM table AS t

Quoted identifiers according to ANSI SQL:

SELECT "column" FROM "db"."table"

Usability Improvements

Type casting for Merge-type tables

input_format_allow_errors_* settings

Loading part of configuration from ZK

OPTIMIZE TABLE ... PARTITION ... DEDUPLICATE

ALTER of primary key: Enum, Date <-> UInt16, DateTime <-> UInt32

Distributed Queries

Distributed DDL queries:

CREATE TABLE table ON CLUSTER cluster ...

Disabling lagging replicas

Disabling replicas without the table

Original query source in system.processes, system.query_log

Dictionaries

Dictionary table engine, Dictionary database engine:

CREATE DATABASE dictionaries ENGINE = Dictionary

Reloading dictionaries using user-defined state query

IP Trie dictionaries

INSERT SELECT Convenience

Type casting in INSERT SELECT

INSERT SELECT: by positions instead of names

GIS Functions

pointInEllipses

greatCircleDistance

Aggregate Functions

-ForEach combinator

groupArrayInsertAt

topK (beta)

Interfaces

ODBC driver — build and functionality on Windows

HTTPS server

NULLs (beta gamma)

NULL for JOIN: join_use_nulls setting

NULLS FIRST, LAST for ORDER BY

NULL support in IN

NULL support in higher-order functions

if, multiIf, ifNull, nullIf, coalesce

toNullable, assumeNotNull

Nullable type support in aggregate functions

NULL as result of subquery returning empty set

And More

ALTER ... CLEAR COLUMN ... IN PARTITION

preferred_block_size_bytes setting

But That's Not All

KILL QUERY
LIMIT BY
SELECT INTO OUTFILE
clickhouse-local
cross-replication
UUID and MAC encoding functions
Proper HTTP response codes
Proper comparison operation logic
Progress in HTTP headers
Cache stampede fix
system.build_options, system.graphite
Distributed query tracing in system.processes, system.query_log
Ability to skip errors in text formats
fsync_metadata setting
timezone config parameter, timezone() function
decodeURLComponent
Faster gzip in HTTP interface
max_table_size_to_drop
proper build and packages
DISTINCT speedup
Buffer table optimization
FixedString optimization
RIGHT/FULL JOIN improvements
clickhouse --extract-from-config
system.parts - exact row count
system.columns - uncompressed size
system.part_log

Roadmap

July 2017

SYSTEM queries

Limit on concurrent replica downloads

NULLs: fix almost all remaining issues

Q3-Q4 2017

Custom partitioning key for MergeTree

Ability to write JOIN as in regular SQL

Resource pools (CPU, disk IO, network bandwidth) for queries

Q4-Q5 2017

Initial UPDATE/DELETE support

Community

Website: https://clickhouse.com/

Google groups: https://groups.google.com/forum/#!forum/clickhouse

Mailing list: [email protected]

Telegram chat: https://telegram.me/clickhouse_en and https://telegram.me/clickhouse_ru (already 778 participants)

GitHub: https://github.com/ClickHouse/ClickHouse/

 

+ meetings. Moscow, Saint Petersburg, Novosibirsk, San Francisco
Ekaterinburg, Minsk... Next: Nizhny Novgorod, Kazan, Berlin

Thank You!