SlideShare una empresa de Scribd logo
1 de 48
Descargar para leer sin conexión
Introduction to Presenter
www.altinity.com
Leading software and services
provider for ClickHouse
Major committer and community
sponsor in US and Western Europe
Robert Hodges - Altinity CEO
30+ years on DBMS plus
virtualization and security.
ClickHouse is DBMS #20
Introduction to ClickHouse
Understands SQL
Runs on bare metal to cloud
Shared nothing architecture
Uses column storage
Parallel and vectorized execution
Scales to many petabytes
Is Open source (Apache 2.0)
a b c d
a b c d
a b c d
a b c d
And it’s really fast!
© 2019, Altinity LTD
Send server log
to client to see
query processing
Enabling server logs in clickhouse-client
clickhouse-client --send_logs_level=trace
(OR)
my-host :) SET send_logs_level = 'trace'
my-host :) SELECT 1
my-host :) SET send_logs_level = 'none'
Ask for logs at start
of the session
Ask for logs during
the session
It works in Python too!
# Configure logging.
import logging
logging.basicConfig(level=logging.DEBUG)
# Execute a query using log settings.
from clickhouse_driver import Client
client = Client('localhost')
settings = {'send_logs_level': 'trace'}
result = client.execute('SELECT 1', settings=settings)
print("RESULT: {0}".format(result))
Sends logs
to stdout
© 2019, Altinity LTD
Use encodings
to reduce data
size
© 2019, Altinity LTD
CREATE TABLE test_codecs ( a String,
a_lc LowCardinality(String) DEFAULT a,
b UInt32,
b_delta UInt32 DEFAULT b Codec(Delta),
b_delta_lz4 UInt32 DEFAULT b Codec(Delta, LZ4),
b_dd UInt32 DEFAULT b Codec(DoubleDelta),
b_dd_lz4 UInt32 DEFAULT b Codec(DoubleDelta, LZ4)
)
Engine = MergeTree
PARTITION BY tuple() ORDER BY tuple();
Applying encodings to table columns
Values with
dictionary
encoding
Differences
between
values
Differences
between change
of value
© 2019, Altinity LTD
INSERT INTO test_codecs (a, b)
SELECT
concat('a string prefix',
toString(rand() % 1000)),
now() + (number * 10)
FROM system.numbers
LIMIT 100000000
SETTINGS max_block_size=1000000
Load lots of data
© 2019, Altinity LTD
SELECT name, sum(data_compressed_bytes) comp,
sum(data_uncompressed_bytes) uncomp,
round(comp / uncomp * 100.0, 2) AS percent
FROM system.columns WHERE table = 'test_codecs'
GROUP BY name ORDER BY name
┌─name────────┬──────comp─┬─────uncomp─┬─percent─┐
│ a │ 393712480 │ 1888998884 │ 20.84 │
│ a_lc │ 201150993 │ 200431356 │ 100.36 │
│ b │ 401727287 │ 400000000 │ 100.43 │
│ b_delta │ 400164862 │ 400000000 │ 100.04 │
│ b_delta_lz4 │ 1971602 │ 400000000 │ 0.49 │
│ b_dd │ 12738212 │ 400000000 │ 3.18 │
│ b_dd_lz4 │ 476375 │ 400000000 │ 0.12 │
└─────────────┴───────────┴────────────┴─────────┘
Check data sizes
LowCardinality
total compression
is a_lc comp / a
uncomp = 10.65%
© 2019, Altinity LTD
SELECT a AS a, count(*) AS c FROM test_codecs
GROUP BY a ORDER BY c ASC LIMIT 10
. . .
10 rows in set. Elapsed: 0.681 sec. Processed 100.00 million
rows, 2.69 GB (146.81 million rows/s., 3.95 GB/s.)
SELECT a_lc AS a, count(*) AS c FROM test_codecs
GROUP BY a ORDER BY c ASC LIMIT 10
. . .
10 rows in set. Elapsed: 0.148 sec. Processed 100.00 million
rows, 241.16 MB (675.55 million rows/s., 1.63 GB/s.)
But wait, there’s more! Encodings help query speed
Faster
© 2019, Altinity LTD
Quick Comparison of Encodings
Name Best for
LowCardinality Strings with fewer than 10K values
Delta Time series
Double Delta Increasing counters
Gorilla Gauge data (bounces around mean)
T64 Integers other than random hashes
Compression may vary across ZSTD and LZ4
© 2019, Altinity LTD
Use
materialized
views to find
last point data
© 2019, Altinity LTD
Last point problems are common in time series
Host
7023
Host
6522
CPU
Utilization
Host
9601
CPU
Utilization
CPU
UtilizationCPU
Utilization
CPU
UtilizationCPU
Utilization
CPU Table
Problem: Show the
current CPU utilization for
each host
CPU
Utilization
CPU
Utilization
© 2019, Altinity LTD
argMaxState links columns with aggregates
CREATE MATERIALIZED VIEW cpu_last_point_idle_mv
ENGINE = AggregatingMergeTree()
PARTITION BY tuple()
ORDER BY tags_id
POPULATE
AS SELECT
argMaxState(created_date, created_at) AS created_date,
maxState(created_at) AS max_created_at,
argMaxState(time, created_at) AS time,
tags_id,
argMaxState(usage_idle, created_at) AS usage_idle
FROM cpu
GROUP BY tags_id
Matching
data
Max value
Don’t partition
© 2019, Altinity LTD
Let’s hide the merge details with a view
CREATE VIEW cpu_last_point_idle_v AS
SELECT
argMaxMerge(created_date) AS created_date,
maxMerge(max_created_at) AS created_at,
argMaxMerge(time) AS time,
tags_id,
argMaxMerge(usage_idle) AS usage_idle
FROM cpu_last_point_idle_mv
GROUP BY tags_id
Merge functions roll up
partial aggregate data
© 2019, Altinity LTD
...Select from the covering view
SELECT
tags_id,
100 - usage_idle usage
FROM cpu_last_point_idle_v
ORDER BY usage DESC, tags_id ASC
LIMIT 10
...
10 rows in set. Elapsed: 0.005 sec. Processed 14.00
thousand rows, 391.65 KB (2.97 million rows/s., 82.97
MB/s.)
© 2019, Altinity LTD
Use arrays to
store key-value
pairs
© 2019, Altinity LTD
CREATE TABLE cpu (
created_date Date DEFAULT today(),
created_at DateTime DEFAULT now(),
time String,
tags_id UInt32,
usage_user Float64,
usage_system Float64,
. . .
additional_tags String DEFAULT '')
ENGINE = MergeTree()
PARTITION BY created_date
ORDER BY (tags_id, created_at)
SQL tables typically have a tabular form
© 2019, Altinity LTD
CREATE TABLE cpu_dynamic (
created_date Date,
created_at DateTime,
time String,
tags_id UInt32,
metrics_name Array(String),
metrics_value Array(Float64)
)
ENGINE = MergeTree()
PARTITION BY created_date
ORDER BY (tags_id, created_at)
Paired arrays allow flexible values
Measurement
names
Floating point
values
© 2019, Altinity LTD
clickhouse-client --database default 
--query="INSERT INTO cpu_dynamic FORMAT JSONEachRow"
<<DATA
{"created_date":"2016-01-03",
"created_at":"2016-01-03 00:00:00",
"time":"2016-01-03 00:00:00 +0000",
"tags_id":6220,
"metrics_name":["usage_user","usage_system",
"usage_idle","usage_nice"],
"metrics_value":[35,47,77,21]}
. . .
DATA
Insert some values from JSON
© 2019, Altinity LTD
SELECT time, tags_id, metrics_name,metrics_value
FROM cpu_dynamic
Row 1:
──────
time: 2016-01-03 00:00:00 +0000
tags_id: 6220
metrics_name:
['usage_user','usage_system','usage_idle','usage_nice']
metrics_value: [35,47,77,21]
. . .
Now each row can have different key/value pairs
© 2019, Altinity LTD
SELECT created_at, tags_id, name, value
FROM cpu_dynamic
ARRAY JOIN metrics_name AS name, metrics_value AS value
┌──────────created_at─┬─tags_id─┬─name─────────┬─value─┐
│ 2016-01-03 00:00:00 │ 6220 │ usage_user │ 35 │
│ 2016-01-03 00:00:00 │ 6220 │ usage_system │ 47 │
│ 2016-01-03 00:00:00 │ 6220 │ usage_idle │ 77 │
│ 2016-01-03 00:00:00 │ 6220 │ usage_nice │ 21 │
│ 2016-01-03 00:00:10 │ 6220 │ usage_nice │ 21 │
│ 2016-01-03 00:00:10 │ 6220 │ usage_iowait │ 84 │
│ 2016-01-03 00:00:10 │ 6220 │ usage_irq │ 22 │
You can pivot back to a tabular form with ARRAY JOIN
Correlated arrays
© 2019, Altinity LTD
Use materialized
columns to pre-
compute values
© 2019, Altinity LTD
ALTER TABLE cpu_dynamic ADD COLUMN usage_user MATERIALIZED
metrics_value[indexOf(metrics_name, 'usage_user')]
AFTER tags_id
SELECT time, tags_id, usage_user
FROM cpu_dynamic
┌─time──────────────────────┬─tags_id─┬─usage_user─┐
│ 2016-01-03 00:00:00 +0000 │ 6220 │ 35 │
│ 2016-01-03 00:00:10 +0000 │ 6220 │ 0 │
└───────────────────────────┴─────────┴────────────┘
You can create new columns using MATERIALIZED
Computed for
old data
Materialized
for new data
© 2019, Altinity LTD
Use dictionaries
instead of joins
for dimensions
© 2019, Altinity LTD
Star schemas are common in data warehouse
CPU Table
Tags TableOrgs Table
Budgets Table Projects Table
Facts
Dimension
© 2019, Altinity LTD
SELECT tags.rack rack, avg(100 - cpu.usage_idle) usage
FROM cpu
INNER JOIN tags AS t ON cpu.tags_id = t.id
GROUP BY rack
ORDER BY usage DESC
LIMIT 10
Matching data
Joining facts and dimensions is not always convenient
Need a join for
every dimension
Dimension values are often mutable
© 2019, Altinity LTD
/etc/clickhouse-server/tags_dictionary.xml:
<yandex><dictionary>
<name>tags</name>
<source> <mysql>
<host>localhost</host> <port>3306</port>
<user>root</user> <password>********</password>
<db>tsbs</db> <table>tags</table>
</mysql> </source>
<layout> <hashed/> </layout>
<structure>
<id> <name>id</name> </id>
<attribute>
<name>hostname</name><type>String</type>
<null_value></null_value>
</attribute> . . .
Dictionaries are an alternative to joins
© 2019, Altinity LTD
SELECT
dictGetString('tags', 'rack', toUInt64(cpu.tags_id)) rack,
avg(100 - cpu.usage_idle) usage
FROM cpu
GROUP BY rack
ORDER BY usage DESC
LIMIT 10
Now we can avoid costly joins
Dictionary key must
be UInt64
Hash table stored in memory
© 2019, Altinity LTD
External dictionaries live in another location
CPU Table
Tags Table
Orgs Table Budgets Table
Projects Table
Small, mutable dimensionsLarge, immutable facts
ClickHouse
MySQL or PostgreSQL
© 2019, Altinity LTD
Use MySQL
Database Engine
instead of
dictionaries
© 2019, Altinity LTD
Access a MySQL database from ClickHouse
CREATE DATABASE mysql_repl
ENGINE=MySQL(
'127.0.0.1:3306',
'repl',
'root',
'secret')
use mysql_repl
show tables
Database engine
© 2019, Altinity LTD
Selecting data from MySQL
SELECT
t.datetime, t.date, t.request_id,
t.name customer, s.name sku
FROM (
SELECT t.* FROM traffic t
JOIN customer c ON t.customer_id = c.id) AS t
JOIN mysql_repl.sku s ON t.sku_id = s.id
WHERE customer_id = 5
ORDER BY t.request_id LIMIT 10
Predicate pushed
down to MySQL
© 2019, Altinity LTD
Use TTLs to
delete obsolete
data
© 2019, Altinity LTD
ClickHouse is not optimized for deletes
CREATE TABLE traffic (
datetime DateTime,
date Date,
request_id UInt64,
cust_id UInt32,
sku UInt32
) ENGINE = MergeTree
PARTITION BY toYYYYMM(datetime)
ORDER BY (cust_id, date)
© 2019, Altinity LTD
Until 2019 there were two options
ALTER TABLE traffic DROP PARTITION 201801
ALTER TABLE traffic DELETE WHERE
datetime < toDateTime('2018-02-01 00:00:00')
Drop entire
partition; very fast
Drop matching values
asynchronously
© 2019, Altinity LTD
You can delete automatically with a TTL
CREATE TABLE traffic (
datetime DateTime,
date Date,
request_id UInt64,
cust_id UInt32,
sku UInt32
) ENGINE = MergeTree
PARTITION BY toYYYYMM(datetime)
ORDER BY (cust_id, date)
TTL datetime + INTERVAL 90 DAY
Drop rows after
90 days
TTL application set by
merge_with_ttl_timeout
in merge_tree_settings
© 2019, Altinity LTD
TTL value can be variable based on data
CREATE TABLE traffic_with_ttl_variable (
datetime DateTime,
date Date,
retention_days UInt16,
request_id UInt64,
cust_id UInt32,
sku UInt32
) ENGINE = MergeTree
PARTITION BY toYYYYMM(datetime)
ORDER BY (cust_id, date)
TTL date + INTERVAL (retention_days * 2) DAY
Custom
retention for
each row
© 2019, Altinity LTD
CREATE TABLE traffic_with_ttl_variable (
datetime DateTime,
date Date,
retention_days UInt16,
request_id UInt64,
cust_id UInt32,
sku UInt32
) ENGINE = MergeTree
PARTITION BY toYYYYMM(datetime)
ORDER BY (cust_id, date)
TTL date + INTERVAL 7 DAY TO DISK 'ssd',
date + INTERVAL 30 DAY TO DISK 'hdd',
date + INTERVAL 180 DAY DELETE
Prepare your brain for more cool TTL uses!!
TTL-based
migration
across tiered
storage
© 2019, Altinity LTD
Use replication
instead of
backups
© 2019, Altinity LTD
Replication works on a per-table basis
Node 1
Table: events
Part: 201801_1_1_0
Part: 201801_2_2_0
Part: 201801_1_2_1
Asynchronous multi-master replication
Node 2
Table: events
Part: 201801_1_1_0
Part: 201801_2_2_0
Part: 201801_1_2_1
INSERT
INSERT
Merge Merge
Replicate
Replicate
DDL +
TRUNCATE
© 2019, Altinity LTD
Clickhouse and Zookeeper implementation
INSERT
Replicate
ClickHouse Node 1
Table: events
(Parts)
ReplicatedMergeTree
:9009
:9000 ClickHouse Node 2
Table: events
(Parts)
ReplicatedMergeTree
:9009
:9000
zookeeper-1
ZNodes
:2181 zookeeper-2
ZNodes
:2181 zookeeper-3
ZNodes
:2181
© 2019, Altinity LTD
Clusters define sharding and replication layouts
/etc/clickhouse-server/config.d/remote_servers.xml:
<yandex>
<remote_servers>
<Replicated>
<shard>
<replica><host>10.0.0.71</host><port>9000</port></replica>
<replica><host>10.0.0.72</host><port>9000</port></replica>
<internal_replication>true</internal_replication>
</shard>
<Replicated>
</remote_servers>
</yandex>
Use ZK-based internal
replication; otherwise,
distributed table sends
INSERTS to all replicas
© 2019, Altinity LTD
Macros enable consistent DDL over a cluster
/etc/clickhouse-server/config.d/macros.xml:
<yandex>
<macros>
<cluster>Replicated</cluster>
<shard>01</shard>
<replica>01</replica>
</macros>
</yandex>
© 2019, Altinity LTD
Zookeeper tag defines servers and task queue
/etc/clickhouse-server/config.d/zookeeper.xml:
<yandex>
<zookeeper>
<node><host>10.0.0.61</host><port>2181</port></node>
<node><host>10.0.0.62</host><port>2181</port></node>
<node><host>10.0.0.63</host><port>2181</port></node>
</zookeeper>
<distributed_ddl>
<path>/clickhouse/ShardedAndReplicated/task_queue/ddl</path>
</distributed_ddl>
</yandex>
Clickhouse restart required after
Zookeeper config changes
© 2019, Altinity LTD
Create tables!
CREATE TABLE events ON CLUSTER '{cluster}' (
EventDate DateTime,
CounterID UInt32,
UserID UInt32)
ENGINE =
ReplicatedMergeTree('/clickhouse/{cluster}/test/tables/events/{
shard}', '{replica}')
PARTITION BY toYYYYMM(EventDate)
ORDER BY (CounterID, EventDate, intHash32(UserID))
Thank you!
Special Offer:
Contact us for a
1-hour consultation!
Presenter:
rhodges@altinity.com
Visit us at:
https://www.altinity.com
Free Consultation:
https://blog.altinity.com/offer

Más contenido relacionado

La actualidad más candente

Your first ClickHouse data warehouse
Your first ClickHouse data warehouseYour first ClickHouse data warehouse
Your first ClickHouse data warehouseAltinity Ltd
 
A Day in the Life of a ClickHouse Query Webinar Slides
A Day in the Life of a ClickHouse Query Webinar Slides A Day in the Life of a ClickHouse Query Webinar Slides
A Day in the Life of a ClickHouse Query Webinar Slides Altinity Ltd
 
A day in the life of a click house query
A day in the life of a click house queryA day in the life of a click house query
A day in the life of a click house queryCristinaMunteanu43
 
All about Zookeeper and ClickHouse Keeper.pdf
All about Zookeeper and ClickHouse Keeper.pdfAll about Zookeeper and ClickHouse Keeper.pdf
All about Zookeeper and ClickHouse Keeper.pdfAltinity Ltd
 
A Practical Introduction to Handling Log Data in ClickHouse, by Robert Hodges...
A Practical Introduction to Handling Log Data in ClickHouse, by Robert Hodges...A Practical Introduction to Handling Log Data in ClickHouse, by Robert Hodges...
A Practical Introduction to Handling Log Data in ClickHouse, by Robert Hodges...Altinity Ltd
 
High Performance, High Reliability Data Loading on ClickHouse
High Performance, High Reliability Data Loading on ClickHouseHigh Performance, High Reliability Data Loading on ClickHouse
High Performance, High Reliability Data Loading on ClickHouseAltinity Ltd
 
Adventures with the ClickHouse ReplacingMergeTree Engine
Adventures with the ClickHouse ReplacingMergeTree EngineAdventures with the ClickHouse ReplacingMergeTree Engine
Adventures with the ClickHouse ReplacingMergeTree EngineAltinity Ltd
 
Introduction to the Mysteries of ClickHouse Replication, By Robert Hodges and...
Introduction to the Mysteries of ClickHouse Replication, By Robert Hodges and...Introduction to the Mysteries of ClickHouse Replication, By Robert Hodges and...
Introduction to the Mysteries of ClickHouse Replication, By Robert Hodges and...Altinity Ltd
 
10 Good Reasons to Use ClickHouse
10 Good Reasons to Use ClickHouse10 Good Reasons to Use ClickHouse
10 Good Reasons to Use ClickHouserpolat
 
Creating Beautiful Dashboards with Grafana and ClickHouse
Creating Beautiful Dashboards with Grafana and ClickHouseCreating Beautiful Dashboards with Grafana and ClickHouse
Creating Beautiful Dashboards with Grafana and ClickHouseAltinity Ltd
 
Altinity Quickstart for ClickHouse-2202-09-15.pdf
Altinity Quickstart for ClickHouse-2202-09-15.pdfAltinity Quickstart for ClickHouse-2202-09-15.pdf
Altinity Quickstart for ClickHouse-2202-09-15.pdfAltinity Ltd
 
Webinar: Strength in Numbers: Introduction to ClickHouse Cluster Performance
Webinar: Strength in Numbers: Introduction to ClickHouse Cluster PerformanceWebinar: Strength in Numbers: Introduction to ClickHouse Cluster Performance
Webinar: Strength in Numbers: Introduction to ClickHouse Cluster PerformanceAltinity Ltd
 
ClickHouse materialized views - a secret weapon for high performance analytic...
ClickHouse materialized views - a secret weapon for high performance analytic...ClickHouse materialized views - a secret weapon for high performance analytic...
ClickHouse materialized views - a secret weapon for high performance analytic...Altinity Ltd
 
Migration to ClickHouse. Practical guide, by Alexander Zaitsev
Migration to ClickHouse. Practical guide, by Alexander ZaitsevMigration to ClickHouse. Practical guide, by Alexander Zaitsev
Migration to ClickHouse. Practical guide, by Alexander ZaitsevAltinity Ltd
 
Data Warehouses in Kubernetes Visualized: the ClickHouse Kubernetes Operator UI
Data Warehouses in Kubernetes Visualized: the ClickHouse Kubernetes Operator UIData Warehouses in Kubernetes Visualized: the ClickHouse Kubernetes Operator UI
Data Warehouses in Kubernetes Visualized: the ClickHouse Kubernetes Operator UIAltinity Ltd
 
ClickHouse Features for Advanced Users, by Aleksei Milovidov
ClickHouse Features for Advanced Users, by Aleksei MilovidovClickHouse Features for Advanced Users, by Aleksei Milovidov
ClickHouse Features for Advanced Users, by Aleksei MilovidovAltinity Ltd
 
Dangerous on ClickHouse in 30 minutes, by Robert Hodges, Altinity CEO
Dangerous on ClickHouse in 30 minutes, by Robert Hodges, Altinity CEODangerous on ClickHouse in 30 minutes, by Robert Hodges, Altinity CEO
Dangerous on ClickHouse in 30 minutes, by Robert Hodges, Altinity CEOAltinity Ltd
 
ClickHouse Mark Cache, by Mik Kocikowski, Cloudflare
ClickHouse Mark Cache, by Mik Kocikowski, CloudflareClickHouse Mark Cache, by Mik Kocikowski, Cloudflare
ClickHouse Mark Cache, by Mik Kocikowski, CloudflareAltinity Ltd
 
ClickHouse Monitoring 101: What to monitor and how
ClickHouse Monitoring 101: What to monitor and howClickHouse Monitoring 101: What to monitor and how
ClickHouse Monitoring 101: What to monitor and howAltinity Ltd
 
Webinar slides: MORE secrets of ClickHouse Query Performance. By Robert Hodge...
Webinar slides: MORE secrets of ClickHouse Query Performance. By Robert Hodge...Webinar slides: MORE secrets of ClickHouse Query Performance. By Robert Hodge...
Webinar slides: MORE secrets of ClickHouse Query Performance. By Robert Hodge...Altinity Ltd
 

La actualidad más candente (20)

Your first ClickHouse data warehouse
Your first ClickHouse data warehouseYour first ClickHouse data warehouse
Your first ClickHouse data warehouse
 
A Day in the Life of a ClickHouse Query Webinar Slides
A Day in the Life of a ClickHouse Query Webinar Slides A Day in the Life of a ClickHouse Query Webinar Slides
A Day in the Life of a ClickHouse Query Webinar Slides
 
A day in the life of a click house query
A day in the life of a click house queryA day in the life of a click house query
A day in the life of a click house query
 
All about Zookeeper and ClickHouse Keeper.pdf
All about Zookeeper and ClickHouse Keeper.pdfAll about Zookeeper and ClickHouse Keeper.pdf
All about Zookeeper and ClickHouse Keeper.pdf
 
A Practical Introduction to Handling Log Data in ClickHouse, by Robert Hodges...
A Practical Introduction to Handling Log Data in ClickHouse, by Robert Hodges...A Practical Introduction to Handling Log Data in ClickHouse, by Robert Hodges...
A Practical Introduction to Handling Log Data in ClickHouse, by Robert Hodges...
 
High Performance, High Reliability Data Loading on ClickHouse
High Performance, High Reliability Data Loading on ClickHouseHigh Performance, High Reliability Data Loading on ClickHouse
High Performance, High Reliability Data Loading on ClickHouse
 
Adventures with the ClickHouse ReplacingMergeTree Engine
Adventures with the ClickHouse ReplacingMergeTree EngineAdventures with the ClickHouse ReplacingMergeTree Engine
Adventures with the ClickHouse ReplacingMergeTree Engine
 
Introduction to the Mysteries of ClickHouse Replication, By Robert Hodges and...
Introduction to the Mysteries of ClickHouse Replication, By Robert Hodges and...Introduction to the Mysteries of ClickHouse Replication, By Robert Hodges and...
Introduction to the Mysteries of ClickHouse Replication, By Robert Hodges and...
 
10 Good Reasons to Use ClickHouse
10 Good Reasons to Use ClickHouse10 Good Reasons to Use ClickHouse
10 Good Reasons to Use ClickHouse
 
Creating Beautiful Dashboards with Grafana and ClickHouse
Creating Beautiful Dashboards with Grafana and ClickHouseCreating Beautiful Dashboards with Grafana and ClickHouse
Creating Beautiful Dashboards with Grafana and ClickHouse
 
Altinity Quickstart for ClickHouse-2202-09-15.pdf
Altinity Quickstart for ClickHouse-2202-09-15.pdfAltinity Quickstart for ClickHouse-2202-09-15.pdf
Altinity Quickstart for ClickHouse-2202-09-15.pdf
 
Webinar: Strength in Numbers: Introduction to ClickHouse Cluster Performance
Webinar: Strength in Numbers: Introduction to ClickHouse Cluster PerformanceWebinar: Strength in Numbers: Introduction to ClickHouse Cluster Performance
Webinar: Strength in Numbers: Introduction to ClickHouse Cluster Performance
 
ClickHouse materialized views - a secret weapon for high performance analytic...
ClickHouse materialized views - a secret weapon for high performance analytic...ClickHouse materialized views - a secret weapon for high performance analytic...
ClickHouse materialized views - a secret weapon for high performance analytic...
 
Migration to ClickHouse. Practical guide, by Alexander Zaitsev
Migration to ClickHouse. Practical guide, by Alexander ZaitsevMigration to ClickHouse. Practical guide, by Alexander Zaitsev
Migration to ClickHouse. Practical guide, by Alexander Zaitsev
 
Data Warehouses in Kubernetes Visualized: the ClickHouse Kubernetes Operator UI
Data Warehouses in Kubernetes Visualized: the ClickHouse Kubernetes Operator UIData Warehouses in Kubernetes Visualized: the ClickHouse Kubernetes Operator UI
Data Warehouses in Kubernetes Visualized: the ClickHouse Kubernetes Operator UI
 
ClickHouse Features for Advanced Users, by Aleksei Milovidov
ClickHouse Features for Advanced Users, by Aleksei MilovidovClickHouse Features for Advanced Users, by Aleksei Milovidov
ClickHouse Features for Advanced Users, by Aleksei Milovidov
 
Dangerous on ClickHouse in 30 minutes, by Robert Hodges, Altinity CEO
Dangerous on ClickHouse in 30 minutes, by Robert Hodges, Altinity CEODangerous on ClickHouse in 30 minutes, by Robert Hodges, Altinity CEO
Dangerous on ClickHouse in 30 minutes, by Robert Hodges, Altinity CEO
 
ClickHouse Mark Cache, by Mik Kocikowski, Cloudflare
ClickHouse Mark Cache, by Mik Kocikowski, CloudflareClickHouse Mark Cache, by Mik Kocikowski, Cloudflare
ClickHouse Mark Cache, by Mik Kocikowski, Cloudflare
 
ClickHouse Monitoring 101: What to monitor and how
ClickHouse Monitoring 101: What to monitor and howClickHouse Monitoring 101: What to monitor and how
ClickHouse Monitoring 101: What to monitor and how
 
Webinar slides: MORE secrets of ClickHouse Query Performance. By Robert Hodge...
Webinar slides: MORE secrets of ClickHouse Query Performance. By Robert Hodge...Webinar slides: MORE secrets of ClickHouse Query Performance. By Robert Hodge...
Webinar slides: MORE secrets of ClickHouse Query Performance. By Robert Hodge...
 

Similar a ClickHouse tips and tricks. Webinar slides. By Robert Hodges, Altinity CEO

Webinar: Secrets of ClickHouse Query Performance, by Robert Hodges
Webinar: Secrets of ClickHouse Query Performance, by Robert HodgesWebinar: Secrets of ClickHouse Query Performance, by Robert Hodges
Webinar: Secrets of ClickHouse Query Performance, by Robert HodgesAltinity Ltd
 
CMP301_Deep Dive on Amazon EC2 Instances
CMP301_Deep Dive on Amazon EC2 InstancesCMP301_Deep Dive on Amazon EC2 Instances
CMP301_Deep Dive on Amazon EC2 InstancesAmazon Web Services
 
20201106 hk-py con-mysql-shell
20201106 hk-py con-mysql-shell20201106 hk-py con-mysql-shell
20201106 hk-py con-mysql-shellIvan Ma
 
How to teach an elephant to rock'n'roll
How to teach an elephant to rock'n'rollHow to teach an elephant to rock'n'roll
How to teach an elephant to rock'n'rollPGConf APAC
 
MySQL Goes to 8! FOSDEM 2020 Database Track, January 2nd, 2020
MySQL Goes to 8!  FOSDEM 2020 Database Track, January 2nd, 2020MySQL Goes to 8!  FOSDEM 2020 Database Track, January 2nd, 2020
MySQL Goes to 8! FOSDEM 2020 Database Track, January 2nd, 2020Geir Høydalsvik
 
Best Practices for Migrating Legacy Data Warehouses into Amazon Redshift
Best Practices for Migrating Legacy Data Warehouses into Amazon RedshiftBest Practices for Migrating Legacy Data Warehouses into Amazon Redshift
Best Practices for Migrating Legacy Data Warehouses into Amazon RedshiftAmazon Web Services
 
Expanding your impact with programmability in the data center
Expanding your impact with programmability in the data centerExpanding your impact with programmability in the data center
Expanding your impact with programmability in the data centerCisco Canada
 
Creating and Using the Flux SQL Datasource | Katy Farmer | InfluxData
Creating and Using the Flux SQL Datasource | Katy Farmer | InfluxData Creating and Using the Flux SQL Datasource | Katy Farmer | InfluxData
Creating and Using the Flux SQL Datasource | Katy Farmer | InfluxData InfluxData
 
Ingesting streaming data for analysis in apache ignite (stream sets theme)
Ingesting streaming data for analysis in apache ignite (stream sets theme)Ingesting streaming data for analysis in apache ignite (stream sets theme)
Ingesting streaming data for analysis in apache ignite (stream sets theme)Tom Diederich
 
Pro Techniques for the SSAS MD Developer
Pro Techniques for the SSAS MD DeveloperPro Techniques for the SSAS MD Developer
Pro Techniques for the SSAS MD DeveloperJens Vestergaard
 
Ssis Best Practices Israel Bi U Ser Group Itay Braun
Ssis Best Practices   Israel Bi U Ser Group   Itay BraunSsis Best Practices   Israel Bi U Ser Group   Itay Braun
Ssis Best Practices Israel Bi U Ser Group Itay Braunsqlserver.co.il
 
IBM MQ Whats new - up to 9.3.4.pptx
IBM MQ Whats new - up to 9.3.4.pptxIBM MQ Whats new - up to 9.3.4.pptx
IBM MQ Whats new - up to 9.3.4.pptxMatt Leming
 
GPSTEC324_STORAGE FOR HPC IN THE CLOUD
GPSTEC324_STORAGE FOR HPC IN THE CLOUDGPSTEC324_STORAGE FOR HPC IN THE CLOUD
GPSTEC324_STORAGE FOR HPC IN THE CLOUDAmazon Web Services
 
GPS: Storage for HPC in the Cloud - GPSTEC324 - re:Invent 2017
GPS: Storage for HPC in the Cloud - GPSTEC324 - re:Invent 2017GPS: Storage for HPC in the Cloud - GPSTEC324 - re:Invent 2017
GPS: Storage for HPC in the Cloud - GPSTEC324 - re:Invent 2017Amazon Web Services
 
Virtual training Intro to Kapacitor
Virtual training  Intro to Kapacitor Virtual training  Intro to Kapacitor
Virtual training Intro to Kapacitor InfluxData
 
Leveraging Open Source to Manage SAN Performance
Leveraging Open Source to Manage SAN PerformanceLeveraging Open Source to Manage SAN Performance
Leveraging Open Source to Manage SAN Performancebrettallison
 
Security benefits of the Nitro architecture - SEP401-R - AWS re:Inforce 2019
Security benefits of the Nitro architecture - SEP401-R - AWS re:Inforce 2019 Security benefits of the Nitro architecture - SEP401-R - AWS re:Inforce 2019
Security benefits of the Nitro architecture - SEP401-R - AWS re:Inforce 2019 Amazon Web Services
 
Monitoring InfluxEnterprise
Monitoring InfluxEnterpriseMonitoring InfluxEnterprise
Monitoring InfluxEnterpriseInfluxData
 
Kauli SSPにおけるVyOSの導入事例
Kauli SSPにおけるVyOSの導入事例Kauli SSPにおけるVyOSの導入事例
Kauli SSPにおけるVyOSの導入事例Kazuhito Ohkawa
 

Similar a ClickHouse tips and tricks. Webinar slides. By Robert Hodges, Altinity CEO (20)

Webinar: Secrets of ClickHouse Query Performance, by Robert Hodges
Webinar: Secrets of ClickHouse Query Performance, by Robert HodgesWebinar: Secrets of ClickHouse Query Performance, by Robert Hodges
Webinar: Secrets of ClickHouse Query Performance, by Robert Hodges
 
CMP301_Deep Dive on Amazon EC2 Instances
CMP301_Deep Dive on Amazon EC2 InstancesCMP301_Deep Dive on Amazon EC2 Instances
CMP301_Deep Dive on Amazon EC2 Instances
 
20201106 hk-py con-mysql-shell
20201106 hk-py con-mysql-shell20201106 hk-py con-mysql-shell
20201106 hk-py con-mysql-shell
 
How to teach an elephant to rock'n'roll
How to teach an elephant to rock'n'rollHow to teach an elephant to rock'n'roll
How to teach an elephant to rock'n'roll
 
MySQL Goes to 8! FOSDEM 2020 Database Track, January 2nd, 2020
MySQL Goes to 8!  FOSDEM 2020 Database Track, January 2nd, 2020MySQL Goes to 8!  FOSDEM 2020 Database Track, January 2nd, 2020
MySQL Goes to 8! FOSDEM 2020 Database Track, January 2nd, 2020
 
Best Practices for Migrating Legacy Data Warehouses into Amazon Redshift
Best Practices for Migrating Legacy Data Warehouses into Amazon RedshiftBest Practices for Migrating Legacy Data Warehouses into Amazon Redshift
Best Practices for Migrating Legacy Data Warehouses into Amazon Redshift
 
Expanding your impact with programmability in the data center
Expanding your impact with programmability in the data centerExpanding your impact with programmability in the data center
Expanding your impact with programmability in the data center
 
Creating and Using the Flux SQL Datasource | Katy Farmer | InfluxData
Creating and Using the Flux SQL Datasource | Katy Farmer | InfluxData Creating and Using the Flux SQL Datasource | Katy Farmer | InfluxData
Creating and Using the Flux SQL Datasource | Katy Farmer | InfluxData
 
Ingesting streaming data for analysis in apache ignite (stream sets theme)
Ingesting streaming data for analysis in apache ignite (stream sets theme)Ingesting streaming data for analysis in apache ignite (stream sets theme)
Ingesting streaming data for analysis in apache ignite (stream sets theme)
 
Pro Techniques for the SSAS MD Developer
Pro Techniques for the SSAS MD DeveloperPro Techniques for the SSAS MD Developer
Pro Techniques for the SSAS MD Developer
 
Ssis Best Practices Israel Bi U Ser Group Itay Braun
Ssis Best Practices   Israel Bi U Ser Group   Itay BraunSsis Best Practices   Israel Bi U Ser Group   Itay Braun
Ssis Best Practices Israel Bi U Ser Group Itay Braun
 
IBM MQ Whats new - up to 9.3.4.pptx
IBM MQ Whats new - up to 9.3.4.pptxIBM MQ Whats new - up to 9.3.4.pptx
IBM MQ Whats new - up to 9.3.4.pptx
 
GPSTEC324_STORAGE FOR HPC IN THE CLOUD
GPSTEC324_STORAGE FOR HPC IN THE CLOUDGPSTEC324_STORAGE FOR HPC IN THE CLOUD
GPSTEC324_STORAGE FOR HPC IN THE CLOUD
 
GPS: Storage for HPC in the Cloud - GPSTEC324 - re:Invent 2017
GPS: Storage for HPC in the Cloud - GPSTEC324 - re:Invent 2017GPS: Storage for HPC in the Cloud - GPSTEC324 - re:Invent 2017
GPS: Storage for HPC in the Cloud - GPSTEC324 - re:Invent 2017
 
Virtual training Intro to Kapacitor
Virtual training  Intro to Kapacitor Virtual training  Intro to Kapacitor
Virtual training Intro to Kapacitor
 
Leveraging Open Source to Manage SAN Performance
Leveraging Open Source to Manage SAN PerformanceLeveraging Open Source to Manage SAN Performance
Leveraging Open Source to Manage SAN Performance
 
PHP tips by a MYSQL DBA
PHP tips by a MYSQL DBAPHP tips by a MYSQL DBA
PHP tips by a MYSQL DBA
 
Security benefits of the Nitro architecture - SEP401-R - AWS re:Inforce 2019
Security benefits of the Nitro architecture - SEP401-R - AWS re:Inforce 2019 Security benefits of the Nitro architecture - SEP401-R - AWS re:Inforce 2019
Security benefits of the Nitro architecture - SEP401-R - AWS re:Inforce 2019
 
Monitoring InfluxEnterprise
Monitoring InfluxEnterpriseMonitoring InfluxEnterprise
Monitoring InfluxEnterprise
 
Kauli SSPにおけるVyOSの導入事例
Kauli SSPにおけるVyOSの導入事例Kauli SSPにおけるVyOSの導入事例
Kauli SSPにおけるVyOSの導入事例
 

Más de Altinity Ltd

Building an Analytic Extension to MySQL with ClickHouse and Open Source.pptx
Building an Analytic Extension to MySQL with ClickHouse and Open Source.pptxBuilding an Analytic Extension to MySQL with ClickHouse and Open Source.pptx
Building an Analytic Extension to MySQL with ClickHouse and Open Source.pptxAltinity Ltd
 
Cloud Native ClickHouse at Scale--Using the Altinity Kubernetes Operator-2022...
Cloud Native ClickHouse at Scale--Using the Altinity Kubernetes Operator-2022...Cloud Native ClickHouse at Scale--Using the Altinity Kubernetes Operator-2022...
Cloud Native ClickHouse at Scale--Using the Altinity Kubernetes Operator-2022...Altinity Ltd
 
Building an Analytic Extension to MySQL with ClickHouse and Open Source
Building an Analytic Extension to MySQL with ClickHouse and Open SourceBuilding an Analytic Extension to MySQL with ClickHouse and Open Source
Building an Analytic Extension to MySQL with ClickHouse and Open SourceAltinity Ltd
 
Fun with ClickHouse Window Functions-2021-08-19.pdf
Fun with ClickHouse Window Functions-2021-08-19.pdfFun with ClickHouse Window Functions-2021-08-19.pdf
Fun with ClickHouse Window Functions-2021-08-19.pdfAltinity Ltd
 
Cloud Native Data Warehouses - Intro to ClickHouse on Kubernetes-2021-07.pdf
Cloud Native Data Warehouses - Intro to ClickHouse on Kubernetes-2021-07.pdfCloud Native Data Warehouses - Intro to ClickHouse on Kubernetes-2021-07.pdf
Cloud Native Data Warehouses - Intro to ClickHouse on Kubernetes-2021-07.pdfAltinity Ltd
 
Building High Performance Apps with Altinity Stable Builds for ClickHouse | A...
Building High Performance Apps with Altinity Stable Builds for ClickHouse | A...Building High Performance Apps with Altinity Stable Builds for ClickHouse | A...
Building High Performance Apps with Altinity Stable Builds for ClickHouse | A...Altinity Ltd
 
Application Monitoring using Open Source - VictoriaMetrics & Altinity ClickHo...
Application Monitoring using Open Source - VictoriaMetrics & Altinity ClickHo...Application Monitoring using Open Source - VictoriaMetrics & Altinity ClickHo...
Application Monitoring using Open Source - VictoriaMetrics & Altinity ClickHo...Altinity Ltd
 
Own your ClickHouse data with Altinity.Cloud Anywhere-2023-01-17.pdf
Own your ClickHouse data with Altinity.Cloud Anywhere-2023-01-17.pdfOwn your ClickHouse data with Altinity.Cloud Anywhere-2023-01-17.pdf
Own your ClickHouse data with Altinity.Cloud Anywhere-2023-01-17.pdfAltinity Ltd
 
ClickHouse ReplacingMergeTree in Telecom Apps
ClickHouse ReplacingMergeTree in Telecom AppsClickHouse ReplacingMergeTree in Telecom Apps
ClickHouse ReplacingMergeTree in Telecom AppsAltinity Ltd
 
Building a Real-Time Analytics Application with Apache Pulsar and Apache Pinot
Building a Real-Time Analytics Application with  Apache Pulsar and Apache PinotBuilding a Real-Time Analytics Application with  Apache Pulsar and Apache Pinot
Building a Real-Time Analytics Application with Apache Pulsar and Apache PinotAltinity Ltd
 
Altinity Webinar: Introduction to Altinity.Cloud-Platform for Real-Time Data.pdf
Altinity Webinar: Introduction to Altinity.Cloud-Platform for Real-Time Data.pdfAltinity Webinar: Introduction to Altinity.Cloud-Platform for Real-Time Data.pdf
Altinity Webinar: Introduction to Altinity.Cloud-Platform for Real-Time Data.pdfAltinity Ltd
 
OSA Con 2022 - What Data Engineering Can Learn from Frontend Engineering - Pe...
OSA Con 2022 - What Data Engineering Can Learn from Frontend Engineering - Pe...OSA Con 2022 - What Data Engineering Can Learn from Frontend Engineering - Pe...
OSA Con 2022 - What Data Engineering Can Learn from Frontend Engineering - Pe...Altinity Ltd
 
OSA Con 2022 - Welcome to OSA CON Version 2022 - Robert Hodges - Altinity.pdf
OSA Con 2022 - Welcome to OSA CON Version 2022 - Robert Hodges - Altinity.pdfOSA Con 2022 - Welcome to OSA CON Version 2022 - Robert Hodges - Altinity.pdf
OSA Con 2022 - Welcome to OSA CON Version 2022 - Robert Hodges - Altinity.pdfAltinity Ltd
 
OSA Con 2022 - Using ClickHouse Database to Power Analytics and Customer Enga...
OSA Con 2022 - Using ClickHouse Database to Power Analytics and Customer Enga...OSA Con 2022 - Using ClickHouse Database to Power Analytics and Customer Enga...
OSA Con 2022 - Using ClickHouse Database to Power Analytics and Customer Enga...Altinity Ltd
 
OSA Con 2022 - Tips and Tricks to Keep Your Queries under 100ms with ClickHou...
OSA Con 2022 - Tips and Tricks to Keep Your Queries under 100ms with ClickHou...OSA Con 2022 - Tips and Tricks to Keep Your Queries under 100ms with ClickHou...
OSA Con 2022 - Tips and Tricks to Keep Your Queries under 100ms with ClickHou...Altinity Ltd
 
OSA Con 2022 - The Open Source Analytic Universe, Version 2022 - Robert Hodge...
OSA Con 2022 - The Open Source Analytic Universe, Version 2022 - Robert Hodge...OSA Con 2022 - The Open Source Analytic Universe, Version 2022 - Robert Hodge...
OSA Con 2022 - The Open Source Analytic Universe, Version 2022 - Robert Hodge...Altinity Ltd
 
OSA Con 2022 - Switching Jaeger Distributed Tracing to ClickHouse to Enable A...
OSA Con 2022 - Switching Jaeger Distributed Tracing to ClickHouse to Enable A...OSA Con 2022 - Switching Jaeger Distributed Tracing to ClickHouse to Enable A...
OSA Con 2022 - Switching Jaeger Distributed Tracing to ClickHouse to Enable A...Altinity Ltd
 
OSA Con 2022 - Streaming Data Made Easy - Tim Spann & David Kjerrumgaard - St...
OSA Con 2022 - Streaming Data Made Easy - Tim Spann & David Kjerrumgaard - St...OSA Con 2022 - Streaming Data Made Easy - Tim Spann & David Kjerrumgaard - St...
OSA Con 2022 - Streaming Data Made Easy - Tim Spann & David Kjerrumgaard - St...Altinity Ltd
 
OSA Con 2022 - State of Open Source Databases - Peter Zaitsev - Percona.pdf
OSA Con 2022 - State of Open Source Databases - Peter Zaitsev - Percona.pdfOSA Con 2022 - State of Open Source Databases - Peter Zaitsev - Percona.pdf
OSA Con 2022 - State of Open Source Databases - Peter Zaitsev - Percona.pdfAltinity Ltd
 
OSA Con 2022 - Specifics of data analysis in Time Series Databases - Roman Kh...
OSA Con 2022 - Specifics of data analysis in Time Series Databases - Roman Kh...OSA Con 2022 - Specifics of data analysis in Time Series Databases - Roman Kh...
OSA Con 2022 - Specifics of data analysis in Time Series Databases - Roman Kh...Altinity Ltd
 

Más de Altinity Ltd (20)

Building an Analytic Extension to MySQL with ClickHouse and Open Source.pptx
Building an Analytic Extension to MySQL with ClickHouse and Open Source.pptxBuilding an Analytic Extension to MySQL with ClickHouse and Open Source.pptx
Building an Analytic Extension to MySQL with ClickHouse and Open Source.pptx
 
Cloud Native ClickHouse at Scale--Using the Altinity Kubernetes Operator-2022...
Cloud Native ClickHouse at Scale--Using the Altinity Kubernetes Operator-2022...Cloud Native ClickHouse at Scale--Using the Altinity Kubernetes Operator-2022...
Cloud Native ClickHouse at Scale--Using the Altinity Kubernetes Operator-2022...
 
Building an Analytic Extension to MySQL with ClickHouse and Open Source
Building an Analytic Extension to MySQL with ClickHouse and Open SourceBuilding an Analytic Extension to MySQL with ClickHouse and Open Source
Building an Analytic Extension to MySQL with ClickHouse and Open Source
 
Fun with ClickHouse Window Functions-2021-08-19.pdf
Fun with ClickHouse Window Functions-2021-08-19.pdfFun with ClickHouse Window Functions-2021-08-19.pdf
Fun with ClickHouse Window Functions-2021-08-19.pdf
 
Cloud Native Data Warehouses - Intro to ClickHouse on Kubernetes-2021-07.pdf
Cloud Native Data Warehouses - Intro to ClickHouse on Kubernetes-2021-07.pdfCloud Native Data Warehouses - Intro to ClickHouse on Kubernetes-2021-07.pdf
Cloud Native Data Warehouses - Intro to ClickHouse on Kubernetes-2021-07.pdf
 
Building High Performance Apps with Altinity Stable Builds for ClickHouse | A...
Building High Performance Apps with Altinity Stable Builds for ClickHouse | A...Building High Performance Apps with Altinity Stable Builds for ClickHouse | A...
Building High Performance Apps with Altinity Stable Builds for ClickHouse | A...
 
Application Monitoring using Open Source - VictoriaMetrics & Altinity ClickHo...
Application Monitoring using Open Source - VictoriaMetrics & Altinity ClickHo...Application Monitoring using Open Source - VictoriaMetrics & Altinity ClickHo...
Application Monitoring using Open Source - VictoriaMetrics & Altinity ClickHo...
 
Own your ClickHouse data with Altinity.Cloud Anywhere-2023-01-17.pdf
Own your ClickHouse data with Altinity.Cloud Anywhere-2023-01-17.pdfOwn your ClickHouse data with Altinity.Cloud Anywhere-2023-01-17.pdf
Own your ClickHouse data with Altinity.Cloud Anywhere-2023-01-17.pdf
 
ClickHouse ReplacingMergeTree in Telecom Apps
ClickHouse ReplacingMergeTree in Telecom AppsClickHouse ReplacingMergeTree in Telecom Apps
ClickHouse ReplacingMergeTree in Telecom Apps
 
Building a Real-Time Analytics Application with Apache Pulsar and Apache Pinot
Building a Real-Time Analytics Application with  Apache Pulsar and Apache PinotBuilding a Real-Time Analytics Application with  Apache Pulsar and Apache Pinot
Building a Real-Time Analytics Application with Apache Pulsar and Apache Pinot
 
Altinity Webinar: Introduction to Altinity.Cloud-Platform for Real-Time Data.pdf
Altinity Webinar: Introduction to Altinity.Cloud-Platform for Real-Time Data.pdfAltinity Webinar: Introduction to Altinity.Cloud-Platform for Real-Time Data.pdf
Altinity Webinar: Introduction to Altinity.Cloud-Platform for Real-Time Data.pdf
 
OSA Con 2022 - What Data Engineering Can Learn from Frontend Engineering - Pe...
OSA Con 2022 - What Data Engineering Can Learn from Frontend Engineering - Pe...OSA Con 2022 - What Data Engineering Can Learn from Frontend Engineering - Pe...
OSA Con 2022 - What Data Engineering Can Learn from Frontend Engineering - Pe...
 
OSA Con 2022 - Welcome to OSA CON Version 2022 - Robert Hodges - Altinity.pdf
OSA Con 2022 - Welcome to OSA CON Version 2022 - Robert Hodges - Altinity.pdfOSA Con 2022 - Welcome to OSA CON Version 2022 - Robert Hodges - Altinity.pdf
OSA Con 2022 - Welcome to OSA CON Version 2022 - Robert Hodges - Altinity.pdf
 
OSA Con 2022 - Using ClickHouse Database to Power Analytics and Customer Enga...
OSA Con 2022 - Using ClickHouse Database to Power Analytics and Customer Enga...OSA Con 2022 - Using ClickHouse Database to Power Analytics and Customer Enga...
OSA Con 2022 - Using ClickHouse Database to Power Analytics and Customer Enga...
 
OSA Con 2022 - Tips and Tricks to Keep Your Queries under 100ms with ClickHou...
OSA Con 2022 - Tips and Tricks to Keep Your Queries under 100ms with ClickHou...OSA Con 2022 - Tips and Tricks to Keep Your Queries under 100ms with ClickHou...
OSA Con 2022 - Tips and Tricks to Keep Your Queries under 100ms with ClickHou...
 
OSA Con 2022 - The Open Source Analytic Universe, Version 2022 - Robert Hodge...
OSA Con 2022 - The Open Source Analytic Universe, Version 2022 - Robert Hodge...OSA Con 2022 - The Open Source Analytic Universe, Version 2022 - Robert Hodge...
OSA Con 2022 - The Open Source Analytic Universe, Version 2022 - Robert Hodge...
 
OSA Con 2022 - Switching Jaeger Distributed Tracing to ClickHouse to Enable A...
OSA Con 2022 - Switching Jaeger Distributed Tracing to ClickHouse to Enable A...OSA Con 2022 - Switching Jaeger Distributed Tracing to ClickHouse to Enable A...
OSA Con 2022 - Switching Jaeger Distributed Tracing to ClickHouse to Enable A...
 
OSA Con 2022 - Streaming Data Made Easy - Tim Spann & David Kjerrumgaard - St...
OSA Con 2022 - Streaming Data Made Easy - Tim Spann & David Kjerrumgaard - St...OSA Con 2022 - Streaming Data Made Easy - Tim Spann & David Kjerrumgaard - St...
OSA Con 2022 - Streaming Data Made Easy - Tim Spann & David Kjerrumgaard - St...
 
OSA Con 2022 - State of Open Source Databases - Peter Zaitsev - Percona.pdf
OSA Con 2022 - State of Open Source Databases - Peter Zaitsev - Percona.pdfOSA Con 2022 - State of Open Source Databases - Peter Zaitsev - Percona.pdf
OSA Con 2022 - State of Open Source Databases - Peter Zaitsev - Percona.pdf
 
OSA Con 2022 - Specifics of data analysis in Time Series Databases - Roman Kh...
OSA Con 2022 - Specifics of data analysis in Time Series Databases - Roman Kh...OSA Con 2022 - Specifics of data analysis in Time Series Databases - Roman Kh...
OSA Con 2022 - Specifics of data analysis in Time Series Databases - Roman Kh...
 

Último

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 

Último (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 

ClickHouse tips and tricks. Webinar slides. By Robert Hodges, Altinity CEO

  • 1.
  • 2. Introduction to Presenter www.altinity.com Leading software and services provider for ClickHouse Major committer and community sponsor in US and Western Europe Robert Hodges - Altinity CEO 30+ years on DBMS plus virtualization and security. ClickHouse is DBMS #20
  • 3. Introduction to ClickHouse Understands SQL Runs on bare metal to cloud Shared nothing architecture Uses column storage Parallel and vectorized execution Scales to many petabytes Is Open source (Apache 2.0) a b c d a b c d a b c d a b c d And it’s really fast!
  • 4. © 2019, Altinity LTD Send server log to client to see query processing
  • 5. Enabling server logs in clickhouse-client clickhouse-client --send_logs_level=trace (OR) my-host :) SET send_logs_level = 'trace' my-host :) SELECT 1 my-host :) SET send_logs_level = 'none' Ask for logs at start of the session Ask for logs during the session
  • 6. It works in Python too! # Configure logging. import logging logging.basicConfig(level=logging.DEBUG) # Execute a query using log settings. from clickhouse_driver import Client client = Client('localhost') settings = {'send_logs_level': 'trace'} result = client.execute('SELECT 1', settings=settings) print("RESULT: {0}".format(result)) Sends logs to stdout
  • 7. © 2019, Altinity LTD Use encodings to reduce data size
  • 8. © 2019, Altinity LTD CREATE TABLE test_codecs ( a String, a_lc LowCardinality(String) DEFAULT a, b UInt32, b_delta UInt32 DEFAULT b Codec(Delta), b_delta_lz4 UInt32 DEFAULT b Codec(Delta, LZ4), b_dd UInt32 DEFAULT b Codec(DoubleDelta), b_dd_lz4 UInt32 DEFAULT b Codec(DoubleDelta, LZ4) ) Engine = MergeTree PARTITION BY tuple() ORDER BY tuple(); Applying encodings to table columns Values with dictionary encoding Differences between values Differences between change of value
  • 9. © 2019, Altinity LTD INSERT INTO test_codecs (a, b) SELECT concat('a string prefix', toString(rand() % 1000)), now() + (number * 10) FROM system.numbers LIMIT 100000000 SETTINGS max_block_size=1000000 Load lots of data
  • 10. © 2019, Altinity LTD SELECT name, sum(data_compressed_bytes) comp, sum(data_uncompressed_bytes) uncomp, round(comp / uncomp * 100.0, 2) AS percent FROM system.columns WHERE table = 'test_codecs' GROUP BY name ORDER BY name ┌─name────────┬──────comp─┬─────uncomp─┬─percent─┐ │ a │ 393712480 │ 1888998884 │ 20.84 │ │ a_lc │ 201150993 │ 200431356 │ 100.36 │ │ b │ 401727287 │ 400000000 │ 100.43 │ │ b_delta │ 400164862 │ 400000000 │ 100.04 │ │ b_delta_lz4 │ 1971602 │ 400000000 │ 0.49 │ │ b_dd │ 12738212 │ 400000000 │ 3.18 │ │ b_dd_lz4 │ 476375 │ 400000000 │ 0.12 │ └─────────────┴───────────┴────────────┴─────────┘ Check data sizes LowCardinality total compression is a_lc comp / a uncomp = 10.65%
  • 11. © 2019, Altinity LTD SELECT a AS a, count(*) AS c FROM test_codecs GROUP BY a ORDER BY c ASC LIMIT 10 . . . 10 rows in set. Elapsed: 0.681 sec. Processed 100.00 million rows, 2.69 GB (146.81 million rows/s., 3.95 GB/s.) SELECT a_lc AS a, count(*) AS c FROM test_codecs GROUP BY a ORDER BY c ASC LIMIT 10 . . . 10 rows in set. Elapsed: 0.148 sec. Processed 100.00 million rows, 241.16 MB (675.55 million rows/s., 1.63 GB/s.) But wait, there’s more! Encodings help query speed Faster
  • 12. © 2019, Altinity LTD Quick Comparison of Encodings Name Best for LowCardinality Strings with fewer than 10K values Delta Time series Double Delta Increasing counters Gorilla Gauge data (bounces around mean) T64 Integers other than random hashes Compression may vary across ZSTD and LZ4
  • 13. © 2019, Altinity LTD Use materialized views to find last point data
  • 14. © 2019, Altinity LTD Last point problems are common in time series Host 7023 Host 6522 CPU Utilization Host 9601 CPU Utilization CPU UtilizationCPU Utilization CPU UtilizationCPU Utilization CPU Table Problem: Show the current CPU utilization for each host CPU Utilization CPU Utilization
  • 15. © 2019, Altinity LTD argMaxState links columns with aggregates CREATE MATERIALIZED VIEW cpu_last_point_idle_mv ENGINE = AggregatingMergeTree() PARTITION BY tuple() ORDER BY tags_id POPULATE AS SELECT argMaxState(created_date, created_at) AS created_date, maxState(created_at) AS max_created_at, argMaxState(time, created_at) AS time, tags_id, argMaxState(usage_idle, created_at) AS usage_idle FROM cpu GROUP BY tags_id Matching data Max value Don’t partition
  • 16. © 2019, Altinity LTD Let’s hide the merge details with a view CREATE VIEW cpu_last_point_idle_v AS SELECT argMaxMerge(created_date) AS created_date, maxMerge(max_created_at) AS created_at, argMaxMerge(time) AS time, tags_id, argMaxMerge(usage_idle) AS usage_idle FROM cpu_last_point_idle_mv GROUP BY tags_id Merge functions roll up partial aggregate data
  • 17. © 2019, Altinity LTD ...Select from the covering view SELECT tags_id, 100 - usage_idle usage FROM cpu_last_point_idle_v ORDER BY usage DESC, tags_id ASC LIMIT 10 ... 10 rows in set. Elapsed: 0.005 sec. Processed 14.00 thousand rows, 391.65 KB (2.97 million rows/s., 82.97 MB/s.)
  • 18. © 2019, Altinity LTD Use arrays to store key-value pairs
  • 19. © 2019, Altinity LTD CREATE TABLE cpu ( created_date Date DEFAULT today(), created_at DateTime DEFAULT now(), time String, tags_id UInt32, usage_user Float64, usage_system Float64, . . . additional_tags String DEFAULT '') ENGINE = MergeTree() PARTITION BY created_date ORDER BY (tags_id, created_at) SQL tables typically have a tabular form
  • 20. © 2019, Altinity LTD CREATE TABLE cpu_dynamic ( created_date Date, created_at DateTime, time String, tags_id UInt32, metrics_name Array(String), metrics_value Array(Float64) ) ENGINE = MergeTree() PARTITION BY created_date ORDER BY (tags_id, created_at) Paired arrays allow flexible values Measurement names Floating point values
  • 21. © 2019, Altinity LTD clickhouse-client --database default --query="INSERT INTO cpu_dynamic FORMAT JSONEachRow" <<DATA {"created_date":"2016-01-03", "created_at":"2016-01-03 00:00:00", "time":"2016-01-03 00:00:00 +0000", "tags_id":6220, "metrics_name":["usage_user","usage_system", "usage_idle","usage_nice"], "metrics_value":[35,47,77,21]} . . . DATA Insert some values from JSON
  • 22. © 2019, Altinity LTD SELECT time, tags_id, metrics_name,metrics_value FROM cpu_dynamic Row 1: ────── time: 2016-01-03 00:00:00 +0000 tags_id: 6220 metrics_name: ['usage_user','usage_system','usage_idle','usage_nice'] metrics_value: [35,47,77,21] . . . Now each row can have different key/value pairs
  • 23. © 2019, Altinity LTD SELECT created_at, tags_id, name, value FROM cpu_dynamic ARRAY JOIN metrics_name AS name, metrics_value AS value ┌──────────created_at─┬─tags_id─┬─name─────────┬─value─┐ │ 2016-01-03 00:00:00 │ 6220 │ usage_user │ 35 │ │ 2016-01-03 00:00:00 │ 6220 │ usage_system │ 47 │ │ 2016-01-03 00:00:00 │ 6220 │ usage_idle │ 77 │ │ 2016-01-03 00:00:00 │ 6220 │ usage_nice │ 21 │ │ 2016-01-03 00:00:10 │ 6220 │ usage_nice │ 21 │ │ 2016-01-03 00:00:10 │ 6220 │ usage_iowait │ 84 │ │ 2016-01-03 00:00:10 │ 6220 │ usage_irq │ 22 │ You can pivot back to a tabular form with ARRAY JOIN Correlated arrays
  • 24. © 2019, Altinity LTD Use materialized columns to pre- compute values
  • 25. © 2019, Altinity LTD ALTER TABLE cpu_dynamic ADD COLUMN usage_user MATERIALIZED metrics_value[indexOf(metrics_name, 'usage_user')] AFTER tags_id SELECT time, tags_id, usage_user FROM cpu_dynamic ┌─time──────────────────────┬─tags_id─┬─usage_user─┐ │ 2016-01-03 00:00:00 +0000 │ 6220 │ 35 │ │ 2016-01-03 00:00:10 +0000 │ 6220 │ 0 │ └───────────────────────────┴─────────┴────────────┘ You can create new columns using MATERIALIZED Computed for old data Materialized for new data
  • 26. © 2019, Altinity LTD Use dictionaries instead of joins for dimensions
  • 27. © 2019, Altinity LTD Star schemas are common in data warehouse CPU Table Tags TableOrgs Table Budgets Table Projects Table Facts Dimension
  • 28. © 2019, Altinity LTD SELECT tags.rack rack, avg(100 - cpu.usage_idle) usage FROM cpu INNER JOIN tags AS t ON cpu.tags_id = t.id GROUP BY rack ORDER BY usage DESC LIMIT 10 Matching data Joining facts and dimensions is not always convenient Need a join for every dimension Dimension values are often mutable
  • 29. © 2019, Altinity LTD /etc/clickhouse-server/tags_dictionary.xml: <yandex><dictionary> <name>tags</name> <source> <mysql> <host>localhost</host> <port>3306</port> <user>root</user> <password>********</password> <db>tsbs</db> <table>tags</table> </mysql> </source> <layout> <hashed/> </layout> <structure> <id> <name>id</name> </id> <attribute> <name>hostname</name><type>String</type> <null_value></null_value> </attribute> . . . Dictionaries are an alternative to joins
  • 30. © 2019, Altinity LTD SELECT dictGetString('tags', 'rack', toUInt64(cpu.tags_id)) rack, avg(100 - cpu.usage_idle) usage FROM cpu GROUP BY rack ORDER BY usage DESC LIMIT 10 Now we can avoid costly joins Dictionary key must be UInt64 Hash table stored in memory
  • 31. © 2019, Altinity LTD External dictionaries live in another location CPU Table Tags Table Orgs Table Budgets Table Projects Table Small, mutable dimensionsLarge, immutable facts ClickHouse MySQL or PostgreSQL
  • 32. © 2019, Altinity LTD Use MySQL Database Engine instead of dictionaries
  • 33. © 2019, Altinity LTD Access a MySQL database from ClickHouse CREATE DATABASE mysql_repl ENGINE=MySQL( '127.0.0.1:3306', 'repl', 'root', 'secret') use mysql_repl show tables Database engine
  • 34. © 2019, Altinity LTD Selecting data from MySQL SELECT t.datetime, t.date, t.request_id, t.name customer, s.name sku FROM ( SELECT t.* FROM traffic t JOIN customer c ON t.customer_id = c.id) AS t JOIN mysql_repl.sku s ON t.sku_id = s.id WHERE customer_id = 5 ORDER BY t.request_id LIMIT 10 Predicate pushed down to MySQL
  • 35. © 2019, Altinity LTD Use TTLs to delete obsolete data
  • 36. © 2019, Altinity LTD ClickHouse is not optimized for deletes CREATE TABLE traffic ( datetime DateTime, date Date, request_id UInt64, cust_id UInt32, sku UInt32 ) ENGINE = MergeTree PARTITION BY toYYYYMM(datetime) ORDER BY (cust_id, date)
  • 37. © 2019, Altinity LTD Until 2019 there were two options ALTER TABLE traffic DROP PARTITION 201801 ALTER TABLE traffic DELETE WHERE datetime < toDateTime('2018-02-01 00:00:00') Drop entire partition; very fast Drop matching values asynchronously
  • 38. © 2019, Altinity LTD You can delete automatically with a TTL CREATE TABLE traffic ( datetime DateTime, date Date, request_id UInt64, cust_id UInt32, sku UInt32 ) ENGINE = MergeTree PARTITION BY toYYYYMM(datetime) ORDER BY (cust_id, date) TTL datetime + INTERVAL 90 DAY Drop rows after 90 days TTL application set by merge_with_ttl_timeout in merge_tree_settings
  • 39. © 2019, Altinity LTD TTL value can be variable based on data CREATE TABLE traffic_with_ttl_variable ( datetime DateTime, date Date, retention_days UInt16, request_id UInt64, cust_id UInt32, sku UInt32 ) ENGINE = MergeTree PARTITION BY toYYYYMM(datetime) ORDER BY (cust_id, date) TTL date + INTERVAL (retention_days * 2) DAY Custom retention for each row
  • 40. © 2019, Altinity LTD CREATE TABLE traffic_with_ttl_variable ( datetime DateTime, date Date, retention_days UInt16, request_id UInt64, cust_id UInt32, sku UInt32 ) ENGINE = MergeTree PARTITION BY toYYYYMM(datetime) ORDER BY (cust_id, date) TTL date + INTERVAL 7 DAY TO DISK 'ssd', date + INTERVAL 30 DAY TO DISK 'hdd', date + INTERVAL 180 DAY DELETE Prepare your brain for more cool TTL uses!! TTL-based migration across tiered storage
  • 41. © 2019, Altinity LTD Use replication instead of backups
  • 42. © 2019, Altinity LTD Replication works on a per-table basis Node 1 Table: events Part: 201801_1_1_0 Part: 201801_2_2_0 Part: 201801_1_2_1 Asynchronous multi-master replication Node 2 Table: events Part: 201801_1_1_0 Part: 201801_2_2_0 Part: 201801_1_2_1 INSERT INSERT Merge Merge Replicate Replicate DDL + TRUNCATE
  • 43. © 2019, Altinity LTD Clickhouse and Zookeeper implementation INSERT Replicate ClickHouse Node 1 Table: events (Parts) ReplicatedMergeTree :9009 :9000 ClickHouse Node 2 Table: events (Parts) ReplicatedMergeTree :9009 :9000 zookeeper-1 ZNodes :2181 zookeeper-2 ZNodes :2181 zookeeper-3 ZNodes :2181
  • 44. © 2019, Altinity LTD Clusters define sharding and replication layouts /etc/clickhouse-server/config.d/remote_servers.xml: <yandex> <remote_servers> <Replicated> <shard> <replica><host>10.0.0.71</host><port>9000</port></replica> <replica><host>10.0.0.72</host><port>9000</port></replica> <internal_replication>true</internal_replication> </shard> <Replicated> </remote_servers> </yandex> Use ZK-based internal replication; otherwise, distributed table sends INSERTS to all replicas
  • 45. © 2019, Altinity LTD Macros enable consistent DDL over a cluster /etc/clickhouse-server/config.d/macros.xml: <yandex> <macros> <cluster>Replicated</cluster> <shard>01</shard> <replica>01</replica> </macros> </yandex>
  • 46. © 2019, Altinity LTD Zookeeper tag defines servers and task queue /etc/clickhouse-server/config.d/zookeeper.xml: <yandex> <zookeeper> <node><host>10.0.0.61</host><port>2181</port></node> <node><host>10.0.0.62</host><port>2181</port></node> <node><host>10.0.0.63</host><port>2181</port></node> </zookeeper> <distributed_ddl> <path>/clickhouse/ShardedAndReplicated/task_queue/ddl</path> </distributed_ddl> </yandex> Clickhouse restart required after Zookeeper config changes
  • 47. © 2019, Altinity LTD Create tables! CREATE TABLE events ON CLUSTER '{cluster}' ( EventDate DateTime, CounterID UInt32, UserID UInt32) ENGINE = ReplicatedMergeTree('/clickhouse/{cluster}/test/tables/events/{ shard}', '{replica}') PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate, intHash32(UserID))
  • 48. Thank you! Special Offer: Contact us for a 1-hour consultation! Presenter: rhodges@altinity.com Visit us at: https://www.altinity.com Free Consultation: https://blog.altinity.com/offer