id
stringlengths
36
36
document
stringlengths
3
3k
metadata
stringlengths
23
69
embeddings
listlengths
384
384
958b91e7-d53b-45b5-bd52-2136514b13a6
slug: /native-protocol/columns sidebar_position: 4 title: 'Column types' description: 'Column types for the native protocol' keywords: ['native protocol columns', 'column types', 'data types', 'protocol data types', 'binary encoding'] doc_type: 'reference' Column types See Data Types for general reference. Nu...
{"source_file": "columns.md"}
[ 0.0378388948738575, 0.06852685660123825, -0.07198382169008255, -0.057035576552152634, -0.051646772772073746, -0.02719017304480076, -0.036110274493694305, -0.010236824862658978, -0.02154158055782318, 0.002893865806981921, -0.008429662324488163, -0.005873852875083685, -0.01995854638516903, -...
b05bb417-576e-4728-830f-7973ba32354e
slug: /native-protocol/hash sidebar_position: 5 title: 'CityHash' description: 'Native protocol hash' doc_type: 'reference' keywords: ['CityHash', 'native protocol hash', 'hash function', 'Google CityHash', 'protocol hashing'] CityHash ClickHouse uses one of the previous versions of CityHash from Google . ::...
{"source_file": "hash.md"}
[ 0.06155507639050484, 0.006975099910050631, 0.06129170209169388, -0.07515265792608261, -0.05419148504734039, -0.06925281882286072, -0.01010225061327219, -0.1011059507727623, -0.09721563011407852, 0.03959296643733978, 0.042455218732357025, -0.019318874925374985, 0.0049203489907085896, -0.060...
c20f0f4f-db76-4b88-823e-5a6e6c5adc64
slug: /native-protocol/server sidebar_position: 3 title: 'Server packets' description: 'Native protocol server' doc_type: 'reference' keywords: ['native protocol', 'tcp protocol', 'client-server', 'protocol specification', 'networking'] Server packets | value | name | description ...
{"source_file": "server.md"}
[ 0.004435721784830093, 0.07022187113761902, -0.022674495354294777, -0.046860795468091965, -0.03833254426717758, -0.06590127944946289, 0.050316717475652695, -0.0060044690035283566, -0.0159465204924345, 0.03794672712683678, -0.008298498578369617, -0.06746979057788849, 0.0137383583933115, -0.0...
fb35e6a4-6def-422c-a809-2a5819276368
Exception {#exception} Server exception during query processing. | field | type | value | description | |-------------|--------|----------------------------------------|------------------------------| | code | Int32 | 60 ...
{"source_file": "server.md"}
[ -0.0024266561958938837, 0.014633086510002613, -0.01722019352018833, 0.07002171128988266, -0.07252220064401627, -0.002185618970543146, 0.0007314191898331046, 0.05356748029589653, -0.017023414373397827, 0.03279782086610794, 0.040469713509082794, -0.06598794460296631, 0.07053352892398834, -0....
d7a97303-46ee-404d-918b-679f3891ebd5
slug: /native-protocol/client sidebar_position: 2 title: 'Native client packets' description: 'Native protocol client' doc_type: 'reference' keywords: ['client packets', 'native protocol client', 'protocol packets', 'client communication', 'TCP client'] Client packets | value | name | description ...
{"source_file": "client.md"}
[ 0.0018228008411824703, 0.03647042438387871, -0.04000090807676315, -0.035530295222997665, -0.11260376125574112, -0.01625850796699524, 0.07195580750703812, 0.02927635796368122, -0.04466196522116661, 0.013462964445352554, -0.02123054303228855, -0.050655145198106766, 0.05697094276547432, 0.027...
fcac8688-70bb-40fd-92ab-d91f2e20d702
Client info {#client-info} | field | type | description | |-------------------|-----------------|--------------------------------| | query_kind | byte | None=0, Initial=1, Secondary=2 | | initial_user | String | Initial user |...
{"source_file": "client.md"}
[ -0.004243410658091307, 0.03497939929366112, -0.0695769190788269, 0.0007738773128949106, -0.08227521926164627, -0.07341881096363068, 0.017274178564548492, -0.0003577361349016428, -0.017824353650212288, 0.01438532117754221, -0.017506379634141922, -0.061085306107997894, 0.11423642933368683, -...
de3c6cda-d2f1-4e7c-b8e4-7980c4b4b3d5
Column {#column} | field | type | value | description | |-------|--------|-----------------|-------------| | name | String | foo | Column name | | type | String | DateTime64(9) | Column type | | data | bytes | ~ | Column data | Cancel {#cancel} No packet body. Server sh...
{"source_file": "client.md"}
[ 0.026333153247833252, 0.07594127207994461, -0.03627076745033264, 0.03495313972234726, -0.12388013303279877, -0.06270658224821091, 0.08074232190847397, -0.015927977859973907, 0.013135664165019989, 0.07592939585447311, 0.00808129832148552, -0.04233961179852486, 0.0032268103677779436, -0.0804...
c9e9fead-8993-4af2-bd7e-4d39abc0560b
slug: /data-compression/compression-modes sidebar_position: 6 title: 'Compression Modes' description: 'ClickHouse column compression modes' keywords: ['compression', 'codec', 'encoding', 'modes'] doc_type: 'reference' import CompressionBlock from '@site/static/images/data-compression/ch_compression_block.png'; impo...
{"source_file": "compression-modes.md"}
[ -0.02005741186439991, 0.03830410912632942, -0.12295497208833694, 0.032412804663181305, 0.07521877437829971, -0.03956444188952446, -0.026150047779083252, 0.010774231515824795, -0.024546122178435326, 0.08812782168388367, 0.03345209360122681, -0.005064848810434341, 0.10490220040082932, -0.020...
9b79ed0b-2c8b-4aaf-98d8-ba23c3c2564a
slug: /data-compression/compression-in-clickhouse title: 'Compression in ClickHouse' description: 'Choosing ClickHouse compression algorithms' keywords: ['compression', 'codec', 'encoding'] doc_type: 'reference' One of the secrets to ClickHouse query performance is compression. Less data on disk means less I/O a...
{"source_file": "compression-in-clickhouse.md"}
[ -0.036050666123628616, 0.019397076219320297, -0.04516880214214325, 0.00883796438574791, 0.0009389352053403854, -0.09428601711988449, -0.017937209457159042, -0.04133738577365875, 0.02387407049536705, 0.03213467821478844, -0.018179453909397125, 0.07356150448322296, 0.02776510640978813, -0.04...
e0e1b615-0e31-4c2f-a07e-97bd675cf365
┌─name──────────────────┬─compressed_size─┬─uncompressed_size─┬───ratio────┐ │ Body │ 46.14 GiB │ 127.31 GiB │ 2.76 │ │ Title │ 1.20 GiB │ 2.63 GiB │ 2.19 │ │ Score │ 84.77 MiB │ 736.45 MiB │ 8.69 │ │ Tags ...
{"source_file": "compression-in-clickhouse.md"}
[ 0.015027021989226341, -0.0526832714676857, 0.006598168518394232, 0.020448734983801842, 0.03132835403084755, -0.10108183324337006, 0.029608692973852158, 0.013546976260840893, 0.026732545346021652, 0.10334447771310806, 0.055872779339551926, -0.011402479372918606, 0.0794132798910141, -0.01013...
dac8757c-6ee9-46f7-b7dd-4690f28e01c4
-- Check the type of the parts SELECT table, name, part_type from system.parts where table = 'compact'; -- Get the compressed and uncompressed column sizes for the compact table SELECT name, formatReadableSize(sum(data_compressed_bytes)) AS compressed_size, formatReadableSize(sum(data_uncompressed_bytes)) AS unc...
{"source_file": "compression-in-clickhouse.md"}
[ 0.04902243614196777, 0.03046952188014984, -0.0347476564347744, 0.02494169771671295, -0.05100683495402336, -0.07041218876838684, -0.003430071519687772, 0.07068217545747757, -0.07343252748250961, 0.018970392644405365, -0.05511998012661934, -0.03962622955441475, 0.043810147792100906, -0.08446...
79ad882c-8a86-4f79-93ba-dcf8e0c039a7
To summarize the total size of the table, we can simplify the above query: ```sql SELECT formatReadableSize(sum(data_compressed_bytes)) AS compressed_size, formatReadableSize(sum(data_uncompressed_bytes)) AS uncompressed_size, round(sum(data_uncompressed_bytes) / sum(data_compressed_bytes), 2) AS ratio FROM s...
{"source_file": "compression-in-clickhouse.md"}
[ 0.03525036945939064, 0.024780817329883575, -0.03551813215017319, 0.05685805529356003, 0.01986011303961277, -0.03926938772201538, -0.026303470134735107, 0.01550241932272911, -0.019987894222140312, 0.06466522812843323, -0.05449625104665756, 0.020860863849520683, 0.05004866048693657, -0.01704...
0176fa3e-e094-44b5-aabc-0e44f09ab66a
┌─name──────────────────┬─compressed_size─┬─uncompressed_size─┬───ratio─┐ │ Body │ 23.10 GiB │ 63.63 GiB │ 2.75 │ │ Title │ 614.65 MiB │ 1.28 GiB │ 2.14 │ │ Score │ 40.28 MiB │ 227.38 MiB │ 5.65 │ │ Tags ...
{"source_file": "compression-in-clickhouse.md"}
[ 0.018732242286205292, -0.06894560158252716, 0.018451305106282234, 0.013258613646030426, 0.03240467235445976, -0.08122909069061279, 0.034677211195230484, 0.01409154199063778, 0.012783966027200222, 0.10955251008272171, 0.05511021241545677, -0.019869789481163025, 0.09069673717021942, -0.00935...
3eb79330-268d-4002-a872-e556991c7eff
Recommendation | Reasoning --- | --- ZSTD all the way | ZSTD compression offers the best rates of compression. ZSTD(1) should be the default for most common types. Higher rates of compression can be ...
{"source_file": "compression-in-clickhouse.md"}
[ -0.12997876107692719, 0.056505195796489716, 0.0033250891137868166, -0.0446295328438282, -0.006269047036767006, -0.013885898515582085, -0.09954684972763062, 0.05104963853955269, 0.015970982611179352, -0.024929359555244446, -0.044878654181957245, 0.020025018602609634, -0.04108434543013573, 0...
d1717924-0d96-449b-8bb9-d56c0bfdaec0
Below we specify the Delta codec for the Id , ViewCount and AnswerCount , hypothesizing these will be linearly correlated with the ordering key and thus should benefit from Delta encoding. sql CREATE TABLE posts_v4 ( `Id` Int32 CODEC(Delta, ZSTD), `PostTypeId` Enum('Question' = 1, 'Answer' = 2, ...
{"source_file": "compression-in-clickhouse.md"}
[ 0.012072579935193062, -0.021897494792938232, -0.07786715030670166, 0.02678149752318859, -0.07324262708425522, 0.0386328399181366, 0.020664367824792862, -0.016610797494649887, -0.018593646585941315, 0.040783852338790894, 0.0751587301492691, -0.05160560831427574, 0.05160226300358772, -0.0238...
d27fb03d-43d8-4b78-8184-9e7eb9d9cd78
6 rows in set. Elapsed: 0.008 sec ``` Compression in ClickHouse Cloud {#compression-in-clickhouse-cloud} In ClickHouse Cloud, we utilize the ZSTD compression algorithm (with a default value of 1) by default. While compression speeds can vary for this algorithm, depending on the compression level (higher = slower)...
{"source_file": "compression-in-clickhouse.md"}
[ -0.1053967997431755, 0.07763862609863281, -0.024018630385398865, -0.017347339540719986, 0.036566417664289474, -0.04249409958720207, -0.041641633957624435, -0.045778971165418625, -0.0000210512680496322, 0.04741424694657326, -0.037147026509046555, 0.07800410687923431, 0.032830655574798584, -...
dc106997-e611-44e7-aa5d-6f2effda37ae
slug: /data-modeling/denormalization title: 'Denormalizing Data' description: 'How to use denormalization to improve query performance' keywords: ['data denormalization', 'denormalize', 'query optimization'] doc_type: 'guide' import denormalizationDiagram from '@site/static/images/data-modeling/denormalization-diag...
{"source_file": "denormalization.md"}
[ 0.032279618084430695, 0.03521018847823143, 0.002250590594485402, 0.04116524010896683, -0.01685839705169201, -0.1262473165988922, -0.019487397745251656, 0.06235882267355919, -0.07713404297828674, -0.0010070427088066936, 0.04125042259693146, 0.06544003635644913, 0.1176031157374382, 0.0285825...
8b3c35ec-8575-414e-9649-a22adee3b580
The denormalization work can be handled in either ClickHouse or upstream e.g. using Apache Flink. Avoid denormalization on frequently updated data {#avoid-denormalization-on-frequently-updated-data} For ClickHouse, denormalization is one of several options users can use in order to optimize query performance but sh...
{"source_file": "denormalization.md"}
[ -0.044286929070949554, -0.00996240135282278, 0.021806251257658005, 0.04134209826588631, -0.03729322925209999, -0.08524367213249207, -0.04173165559768677, -0.007594998925924301, -0.014905404299497604, 0.007248334586620331, 0.016503753140568733, 0.024745719507336617, -0.024831311777234077, -...
23c0cf63-ac54-4295-a8ea-c59ca1d36338
For each of the following examples, assume a query exists which requires both tables to be used in a join. Posts and Votes {#posts-and-votes} Votes for posts are represented as separate tables. The optimized schema for this is shown below as well as the insert command to load the data: ``sql CREATE TABLE votes ( ...
{"source_file": "denormalization.md"}
[ -0.028775684535503387, -0.0368080772459507, -0.05290713533759117, 0.0173045564442873, -0.014818333089351654, -0.0478881411254406, -0.03054053895175457, -0.025326179340481758, -0.0062642949633300304, 0.007527371868491173, 0.02437019906938076, -0.011751668527722359, 0.0727638378739357, -0.07...
ac04cb8f-18e1-4007-8786-2179eb48c9de
Users and Badges {#users-and-badges} Now let's consider our Users and Badges : We first insert the data with the following command: sql CREATE TABLE users ( `Id` Int32, `Reputation` LowCardinality(String), `CreationDate` DateTime64(3, 'UTC') CODEC(Delta(8), ZSTD(1)), `DisplayName` String,...
{"source_file": "denormalization.md"}
[ -0.01922249235212803, 0.00780197698622942, 0.01185384951531887, 0.058559149503707886, -0.10886700451374054, 0.011525335721671581, 0.09657912701368332, 0.05140989273786545, -0.059622857719659805, -0.03243229165673256, 0.06425385177135468, -0.07243211567401886, 0.11536306887865067, -0.048581...
4911c14d-1c5e-42a3-883b-28c0b5429f7e
We can confirm that no posts have an excessive number of links preventing denormalization: ```sql SELECT PostId, count() AS c FROM postlinks GROUP BY PostId ORDER BY c DESC LIMIT 5 ┌───PostId─┬───c─┐ │ 22937618 │ 125 │ │ 9549780 │ 120 │ │ 3737139 │ 109 │ │ 18050071 │ 103 │ │ 25889234 │ 82 │ └──────────┴─────┘ ``...
{"source_file": "denormalization.md"}
[ -0.03233170881867409, -0.08803779631853104, -0.015176957473158836, 0.05351359024643898, 0.005314184352755547, -0.018452266231179237, -0.08666164427995682, -0.00737358070909977, 0.007979446090757847, 0.06751294434070587, 0.043501850217580795, -0.03931664675474167, 0.02380521222949028, -0.02...
0f0e3a4e-88f9-430b-9125-fca586642124
Each post can contain a number of links to other posts as shown in the PostLinks schema earlier. As a Nested type, we might represent these linked and duplicates posts as follows: sql SET flatten_nested=0 CREATE TABLE posts_with_links ( `Id` Int32 CODEC(Delta(4), ZSTD(1)), ... -other columns `LinkedPosts` N...
{"source_file": "denormalization.md"}
[ -0.05547897517681122, -0.065253846347332, 0.038017068058252335, 0.06173077970743179, -0.05625524744391441, 0.0010110996663570404, -0.06590414047241211, -0.02067689225077629, -0.03273007646203041, 0.050180401653051376, 0.035441480576992035, 0.014865045435726643, 0.05346377566456795, -0.0465...
abd52639-daeb-4d4f-b738-9e282f365678
Users have several options for orchestrating this in ClickHouse, assuming a periodic batch load process is acceptable: Refreshable Materialized Views - Refreshable materialized views can be used to periodically schedule a query with the results sent to a target table. On query execution, the view ensures the targe...
{"source_file": "denormalization.md"}
[ -0.03604015335440636, -0.10361228138208389, -0.06616580486297607, 0.0408422090113163, -0.03709487244486809, -0.03054601140320301, 0.01325790211558342, -0.044285304844379425, -0.03817692771553993, 0.0010593595216050744, -0.04871555417776108, -0.00032534313504584134, 0.004179814830422401, -0...
510aada7-5901-459e-8664-4e5955d49eaa
slug: /data-modeling/backfilling title: 'Backfilling Data' description: 'How to use backfill large datasets in ClickHouse' keywords: ['materialized views', 'backfilling', 'inserting data', 'resilient data load'] doc_type: 'guide' import nullTableMV from '@site/static/images/data-modeling/null_table_mv.png'; import ...
{"source_file": "backfilling.md"}
[ -0.014961384236812592, -0.042474813759326935, -0.05261927470564842, 0.030727006494998932, -0.012567281723022461, -0.04398041218519211, -0.06257332116365433, 0.027471259236335754, -0.09156592190265656, 0.06566619127988815, 0.028490277007222176, 0.017473779618740082, 0.09383125603199005, -0....
f5579cad-ce67-4634-88ef-c36476af74b6
┌─name───────────────┬─type────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ timestamp │ Nullable(DateTime64(6)) │ │ count...
{"source_file": "backfilling.md"}
[ -0.05551200732588768, -0.006464257370680571, -0.04194047674536705, -0.07444610446691513, 0.046000633388757706, -0.025374410673975945, -0.0426378957927227, -0.031479548662900925, -0.10395106673240662, 0.02638222649693489, 0.060843709856271744, 0.0007073086453601718, 0.016485031694173813, -0...
92bf4e87-bbf7-4da7-8eb8-9bd4de70a226
:::note The full PyPI dataset, consisting of over 1 trillion rows, is available in our public demo environment clickpy.clickhouse.com . For further details on this dataset, including how the demo exploits materialized views for performance and how the data is populated daily, see here . ::: Backfilling scenarios {#...
{"source_file": "backfilling.md"}
[ -0.09871774166822433, -0.04060361161828041, -0.04937067627906799, 0.02629479393362999, -0.0021244296804070473, -0.05573083832859993, -0.010481134057044983, -0.03152972087264061, -0.04471750184893608, 0.015312910079956055, -0.018717816099524498, -0.005694309715181589, 0.013436639681458473, ...
01a8e8e7-f2b4-45e1-aee5-daeac6345765
0 rows in set. Elapsed: 15.702 sec. Processed 41.23 million rows, 3.94 GB (2.63 million rows/s., 251.01 MB/s.) Peak memory usage: 977.49 MiB. SELECT count() FROM pypi ┌──count()─┐ │ 20612750 │ -- 20.61 million └──────────┘ 1 row in set. Elapsed: 0.004 sec. SELECT sum(count) FROM pypi_downloads ┌─sum(count)─┐ ...
{"source_file": "backfilling.md"}
[ -0.010568131692707539, -0.05529772862792015, -0.10684043169021606, 0.05707567185163498, -0.051988668739795685, -0.03621058538556099, 0.052291300147771835, 0.031201332807540894, 0.022990774363279343, 0.029715362936258316, -0.0037728138267993927, 0.02251981571316719, 0.03885786235332489, -0....
ee846c14-2a86-4fe2-b61b-d3f5b3bcbc5e
We can now confirm pypi and pypi_downloads contain the complete data. pypi_downloads_v2 and pypi_v2 can be safely dropped. ```sql SELECT count() FROM pypi ┌──count()─┐ │ 41012770 │ -- 41.01 million └──────────┘ 1 row in set. Elapsed: 0.003 sec. SELECT sum(count) FROM pypi_downloads ┌─sum(count)─┐ │ ...
{"source_file": "backfilling.md"}
[ -0.057198043912649155, -0.04269878938794136, -0.03136182948946953, 0.033609550446271896, 0.022928981110453606, -0.06108548864722252, 0.04005450755357742, 0.0710705891251564, 0.07225129753351212, 0.0395318977534771, 0.02046957053244114, 0.02430151402950287, 0.011794027872383595, -0.01898828...
89d6a310-eb89-430a-9ee6-bc896d15a4d9
Identify the checkpoint - either a timestamp or column value from which historical data needs to be restored. Create duplicates of the main table and target tables for materialized views. Create copies of any materialized views pointing to the target tables created in step (2). Insert into our duplicate main tabl...
{"source_file": "backfilling.md"}
[ -0.0255739763379097, -0.035963024944067, 0.013920835219323635, -0.011855141259729862, -0.014202360063791275, -0.0730474665760994, 0.04268190637230873, -0.010382365435361862, -0.02692958153784275, 0.008311688899993896, -0.00024798279628157616, 0.013150990940630436, 0.04219822213053703, -0.0...
6b0e84b2-c399-4c4b-91f8-af6549927080
Scenario 2: Adding materialized views to existing tables {#scenario-2-adding-materialized-views-to-existing-tables} It is not uncommon for new materialized views to need to be added to a setup for which significant data has been populated and data is being inserted. A timestamp or monotonically increasing column, whi...
{"source_file": "backfilling.md"}
[ -0.07082760334014893, -0.05162832513451576, -0.06364937126636505, 0.021651268005371094, 0.04707498848438263, -0.0048747593536973, -0.0018650973215699196, -0.03718802332878113, 0.019380616024136543, 0.017572104930877686, 0.019271245226264, -0.029362792149186134, 0.008608819916844368, -0.069...
a5b8d002-edaa-405f-9a40-97c7e9dcb995
Once this view is added, we can backfill all data for the materialized view prior to this data. The simplest means of doing this is to simply run the query from the materialized view on the main table with a filter that ignores recently added data, inserting the results into our view's target table via an INSERT INT...
{"source_file": "backfilling.md"}
[ -0.035836488008499146, -0.037610094994306564, -0.05141184478998184, 0.09279592335224152, -0.056676462292671204, 0.00900691282004118, 0.021124698221683502, -0.03227581828832626, -0.006316962651908398, 0.05325378477573395, -0.02966783568263054, -0.032903317362070084, 0.05194338411092758, -0....
56caa014-ebed-4bd2-b0bd-1e0bb7bbc34c
Importantly, any materialized views attached to the table engine still execute over blocks of data as its inserted - sending their results to a target table. These blocks are of a configurable size. While larger blocks can potentially be more efficient (and faster to process), they consume more resources (principally m...
{"source_file": "backfilling.md"}
[ -0.05377810820937157, -0.029972612857818604, -0.06075639650225639, 0.039102569222450256, -0.02219700813293457, -0.023996694013476372, -0.04778042063117027, -0.019404081627726555, 0.07214254140853882, 0.03408348560333252, 0.0062682125717401505, -0.03368452936410904, 0.01642860472202301, -0....
5c8acad3-99fe-4a54-9e65-0fad1d64ce47
Insert Parallelism - The number of insert threads used to insert. Controlled through max_insert_threads . In ClickHouse Cloud this is determined by the instance size (between 2 and 4) and is set to 1 in OSS. Increasing this value may improve performance at the expense of greater memory usage. Insert Block Size - ...
{"source_file": "backfilling.md"}
[ -0.033824022859334946, -0.042187467217445374, -0.0421547070145607, -0.005365079268813133, -0.005524412263184786, -0.03715239465236664, -0.08653689175844193, 0.004625312983989716, 0.07056070864200592, 0.04830117151141167, 0.051034942269325256, 0.022622480988502502, 0.0456511490046978, -0.09...
05dfde18-2635-4c47-95d0-d053dee9b876
Ok. 0 rows in set. Elapsed: 43.907 sec. Processed 1.50 billion rows, 33.48 GB (34.06 million rows/s., 762.54 MB/s.) Peak memory usage: 272.53 MiB. ``` Finally, we can reduce memory further by setting min_insert_block_size_rows to 0 (disables it as a deciding factor on block size) and min_insert_block_size_bytes ...
{"source_file": "backfilling.md"}
[ 0.02909902110695839, 0.036743585020303726, -0.0724375769495964, 0.0013607523869723082, -0.0445224866271019, -0.08251521736383438, -0.03106243722140789, 0.0765150710940361, -0.005668250378221273, 0.017755556851625443, -0.005158286076039076, -0.009700847789645195, 0.008027350530028343, -0.01...
c8b56efb-902d-431b-8563-e146d862b726
CREATE MATERIALIZED VIEW pypi_downloads_per_day_mv TO pypi_downloads_per_day AS SELECT toStartOfHour(timestamp) as hour, project, count() AS count FROM pypi GROUP BY hour, project -- (4) Restart inserts. We replicate here by inserting a single row. INSERT INTO pypi SELECT * FROM pypi LIMIT 1 SELECT cou...
{"source_file": "backfilling.md"}
[ -0.008476725779473782, -0.048022691160440445, -0.013505736365914345, 0.04325990378856659, -0.04898823797702789, -0.03317386284470558, 0.040581267327070236, -0.015062747523188591, 0.05115903168916702, 0.038987305015325546, 0.04271216318011284, -0.08262783288955688, 0.06904716789722443, -0.0...
bab1681d-fb0d-458d-b645-465d7cd7d8b1
slug: /data-modeling/overview title: 'Data Modelling Overview' description: 'Overview of Data Modelling' keywords: ['data modelling', 'schema design', 'dictionary', 'materialized view', 'data compression', 'denormalizing data'] doc_type: 'landing-page' Data Modeling This section is about data modeling in ClickHou...
{"source_file": "index.md"}
[ -0.02333972603082657, -0.019384177401661873, -0.0060679432936012745, 0.03779645264148712, -0.0341322235763073, -0.04250597208738327, -0.032515447586774826, -0.006573479622602463, -0.02368849515914917, 0.038679614663124084, 0.0024526729248464108, 0.03085245005786419, 0.0903797373175621, -0....
d4f6b945-bcc9-4c40-b495-6b6285a24f5c
slug: /data-modeling/schema-design title: 'Schema Design' description: 'Optimizing ClickHouse schema for query performance' keywords: ['schema', 'schema design', 'query optimization'] doc_type: 'guide' import stackOverflowSchema from '@site/static/images/data-modeling/stackoverflow-schema.png'; import schemaDesignI...
{"source_file": "schema-design.md"}
[ -0.014195442199707031, -0.015552611090242863, -0.004609585739672184, 0.037216849625110626, 0.0043616206385195255, -0.07038581371307373, -0.007271952927112579, 0.004725623410195112, -0.06402837485074997, 0.002457721158862114, 0.009811587631702423, 0.014663329347968102, 0.07529600709676743, ...
6914dad1-3165-41e9-a67b-c2e8b46d0ba9
ClickHouse provides a schema inference capability to automatically identify the types for a dataset. This is supported for all data formats, including Parquet. We can exploit this feature to identify the ClickHouse types for the data via s3 table function and DESCRIBE command. Note below we use the glob pattern *.par...
{"source_file": "schema-design.md"}
[ -0.01635614037513733, -0.07254599779844284, -0.07616287469863892, -0.020219510421156883, -0.0018798382952809334, -0.034355904906988144, 0.030707556754350662, -0.05623132735490799, -0.05428013578057289, 0.013577528297901154, 0.01437213085591793, -0.05020751804113388, -0.016115771606564522, ...
1dc39a9c-1327-46e3-8cbb-edb65b05ad15
The clause ORDER BY () means we have no index, and more specifically no order in our data. More on this later. For now, just know all queries will require a linear scan. To confirm the table has been created: ```sql SHOW CREATE TABLE posts CREATE TABLE posts ( Id Nullable(Int64), PostTypeId ...
{"source_file": "schema-design.md"}
[ 0.04329069331288338, -0.020971208810806274, -0.014751369133591652, 0.08336854726076126, -0.035655293613672256, 0.06514686346054077, 0.003878374118357897, -0.02500816434621811, -0.01553112082183361, 0.09623986482620239, 0.08464671671390533, 0.004175631795078516, 0.10119427740573883, -0.0287...
f7b74cf4-187b-4916-ba7a-3ec6def5836a
For why ClickHouse compresses data so well, we recommend this article . In summary, as a column-oriented database, values will be written in column order. If these values are sorted, the same values will be adjacent to each other. Compression algorithms exploit contiguous patterns of data. On top of this, ClickHouse h...
{"source_file": "schema-design.md"}
[ -0.01311857346445322, 0.04691556841135025, -0.02288949117064476, -0.014050587080419064, -0.042831435799598694, -0.024138620123267174, -0.03934971243143082, -0.023839665576815605, 0.01377923134714365, 0.021926118060946465, -0.036968208849430084, 0.03431257605552673, 0.015860360115766525, -0...
4486887b-d439-4ea5-8291-6637b2d5d5c3
Use LowCardinality - Numbers, strings, Date or DateTime columns with a low number of unique values can potentially be encoded using the LowCardinality type. This dictionary encodes values, reducing the size on disk. Consider this for columns with less than 10k unique values. FixedString for special cases - Strings whi...
{"source_file": "schema-design.md"}
[ -0.003793502924963832, 0.03100484050810337, -0.10073171555995941, -0.03394269570708275, -0.028896937146782875, 0.0034604365937411785, -0.031065503135323524, 0.02684442326426506, 0.008938753046095371, -0.002112468471750617, 0.0021615575533360243, -0.01755502074956894, 0.02875605598092079, 0...
5433b1f7-4ba3-4911-bc93-6b872ccd6118
| Column | Is Numeric | Min, Max | Unique Values | Nulls | Comment | Optimized Type | |------------------------|------------|------...
{"source_file": "schema-design.md"}
[ 0.02567560225725174, -0.0011926016304641962, -0.06033676862716675, 0.0020764777436852455, -0.09470570832490921, 0.03782108426094055, 0.060976963490247726, 0.025806330144405365, -0.027843007817864418, 0.03445541858673096, 0.0657227635383606, -0.03378608450293541, 0.05902000144124031, -0.045...
576221ab-b12e-4ae5-aa5b-396429bcf890
| LastEditorUserId | Yes | -1, 9999993 | 1104694 | Yes | 0 is an unused value can be used for Nulls | Int32 | | LastEditorDisplayName | No |...
{"source_file": "schema-design.md"}
[ 0.07246224582195282, 0.053261008113622665, -0.04887404665350914, 0.046304717659950256, -0.04050883278250694, 0.04809420183300972, 0.04277205467224121, 0.1012502908706665, 0.016008410602808, -0.025603754445910454, 0.04296072572469711, -0.10865738242864609, 0.03802284225821495, -0.0344740338...
4efe36cd-d921-4115-b1e2-541ffdb41a47
| ParentId | No | - | 20696028 | Yes | Consider Null to be an empty string | String | | CommunityOwnedDate | No |...
{"source_file": "schema-design.md"}
[ 0.07706430554389954, 0.07191555202007294, -0.02257552370429039, 0.029711956158280373, -0.06261958181858063, 0.007698889821767807, -0.009800597093999386, 0.08025017380714417, -0.015289925038814545, -0.001012114342302084, 0.10052545368671417, -0.13369879126548767, -0.02058214694261551, -0.05...
8673124d-630a-4bda-a9de-c1147cc43328
The above gives us the following schema: sql CREATE TABLE posts_v2 ( `Id` Int32, `PostTypeId` Enum('Question' = 1, 'Answer' = 2, 'Wiki' = 3, 'TagWikiExcerpt' = 4, 'TagWiki' = 5, 'ModeratorNomination' = 6, 'WikiPlaceholder' = 7, 'PrivilegeWiki' = 8), `AcceptedAnswerId` UInt32, `CreationDate` DateTime, `...
{"source_file": "schema-design.md"}
[ 0.05719456821680069, -0.014544048346579075, -0.0752677246928215, 0.06270253658294678, -0.01656223088502884, -0.01823236234486103, -0.0022314502857625484, 0.02434663102030754, -0.012643390335142612, 0.07335035502910614, 0.07679887115955353, -0.0947636067867279, 0.08826608210802078, -0.02684...
7b0d22f8-8fca-4b7a-85e4-3590ca6611e1
Some simple rules can be applied to help choose an ordering key. The following can sometimes be in conflict, so consider these in order. Users can identify a number of keys from this process, with 4-5 typically sufficient: Select columns which align with your common filters. If a column is used frequently in WHERE...
{"source_file": "schema-design.md"}
[ 0.0435713455080986, 0.03609684854745865, 0.01265793852508068, -0.030274901539087296, 0.03317039832472801, 0.03244040533900261, -0.055185362696647644, -0.019048945978283882, 0.07833625376224518, 0.06246604025363922, -0.012929966673254967, 0.13194938004016876, 0.02129410393536091, -0.0219280...
36d75966-d445-4fe5-aa08-0c8ae3e16857
Lets select the columns PostTypeId and CreationDate as our ordering keys. Maybe in our case, we expect users to always filter by PostTypeId . This has a cardinality of 8 and represents the logical choice for the first entry in our ordering key. Recognizing date granularity filtering is likely to be sufficient (i...
{"source_file": "schema-design.md"}
[ -0.011547444388270378, -0.054309915751218796, 0.037411417812108994, 0.037090010941028595, -0.03947516158223152, -0.01272125355899334, 0.048656709492206573, -0.0229367446154356, -0.0009753731428645551, 0.052199795842170715, 0.047622907906770706, -0.008930218406021595, 0.03450162708759308, -...
53c416c6-6dd9-4e7c-b831-c3766a1a1c14
Through this section, we use optimized variants of our other tables. While we provide the schemas for these, for the sake of brevity we omit the decisions made. These are based on the rules described earlier and we leave inferring the decisions to the reader. The following approaches all aim to minimize the need to...
{"source_file": "schema-design.md"}
[ -0.025006573647260666, 0.01738569885492325, -0.02099020592868328, 0.033252205699682236, 0.011251420713961124, -0.07751701027154922, 0.039440419524908066, 0.043656136840581894, 0.006319581065326929, -0.04895057529211044, 0.0027229462284594774, 0.012464017607271671, 0.08216159045696259, 0.00...
49d26ed8-d7e3-490c-adfd-82a9e9422a0a
slug: /best-practices/use-json-where-appropriate sidebar_position: 10 sidebar_label: 'Using JSON' title: 'Use JSON where appropriate' description: 'Page describing when to use JSON' keywords: ['JSON'] show_related_blogs: true doc_type: 'reference' ClickHouse now offers a native JSON column type designed for semi-st...
{"source_file": "json_type.md"}
[ -0.039739418774843216, 0.005590792745351791, -0.023132706061005592, 0.016025908291339874, -0.015401181764900684, 0.015466805547475815, -0.03815338760614395, 0.02209380269050598, -0.024857481941580772, -0.0553099624812603, 0.07546141743659973, 0.03067149594426155, 0.027820169925689697, 0.07...
b6c6ecf9-90c7-4180-921e-b4621acf00b1
Advanced features {#advanced-features} JSON columns can be used in primary keys like any other columns. Codecs cannot be specified for a subcolumn. They support introspection via functions like JSONAllPathsWithTypes() and JSONDynamicPaths() . You can read nested sub-objects using the .^ syntax. Query s...
{"source_file": "json_type.md"}
[ -0.04395878314971924, 0.0009913841495290399, -0.010641916655004025, 0.013187499716877937, -0.018835991621017456, -0.09325855225324631, -0.02958568185567856, 0.022337976843118668, -0.08210592716932297, -0.042932771146297455, 0.03622554987668991, -0.02258421666920185, -0.003995944280177355, ...
296ddba4-2786-425d-81f3-1842cdbc33c3
sql CREATE TABLE arxiv ( `id` String, `submitter` String, `authors` String, `title` String, `comments` String, `journal-ref` String, `doi` String, `report-no` String, `categories` String, `license` String, `abstract` String, `versions` Array(Tuple(created String, version String)), `update_date...
{"source_file": "json_type.md"}
[ 0.004651025868952274, 0.019346239045262337, 0.0012308586155995727, 0.027229391038417816, -0.12725114822387695, -0.01557585597038269, -0.0626300647854805, 0.0030635064467787743, -0.023996656760573387, 0.05068362131714821, 0.046635664999485016, -0.014581852592527866, 0.04076279699802399, -0....
b4297f79-637d-43e9-bce9-b2ad36bb0a29
sql CREATE TABLE arxiv ( `doc` JSON(update_date Date) ) ENGINE = MergeTree ORDER BY doc.update_date :::note We provide a type hint for the update_date column in the JSON definition, as we use it in the ordering/primary key. This helps ClickHouse to know that this column won't be null and ensures it knows which u...
{"source_file": "json_type.md"}
[ -0.010753166861832142, 0.022250723093748093, 0.075799860060215, 0.049775660037994385, -0.06546176224946976, 0.010688967071473598, -0.12168550491333008, 0.06495014578104019, 0.0024309155996888876, 0.04345264285802841, 0.021378526464104652, 0.005079454742372036, -0.004389593377709389, -0.051...
0b9e49b9-a28f-40e8-a6ff-3d5c07975f9f
Alternatively, we could model this using our earlier schema and a JSON tags column. This is generally preferred, minimizing the inference required by ClickHouse: sql CREATE TABLE arxiv ( `id` String, `submitter` String, `authors` String, `title` String, `comments` String, `journal-ref` Strin...
{"source_file": "json_type.md"}
[ -0.00799941923469305, -0.006655457895249128, -0.003419124521315098, 0.034073635935783386, -0.08099022507667542, -0.024995410814881325, -0.08266585320234299, 0.0068525285460054874, -0.0255180262029171, 0.048512447625398636, 0.038379959762096405, -0.023251069709658623, 0.04525142163038254, -...
e273d51b-7c3d-4b9b-908d-182b032e3b2e
slug: /best-practices/avoid-optimize-final sidebar_position: 10 sidebar_label: 'Avoid optimize final' title: 'Avoid OPTIMIZE FINAL' description: 'Page describing why you should avoid the OPTIMIZE FINAL clause in ClickHouse' keywords: ['avoid OPTIMIZE FINAL', 'background merges'] hide_title: true doc_type: 'guide' A...
{"source_file": "avoid_optimize_final.md"}
[ 0.009339634329080582, 0.12567894160747528, 0.01258156169205904, -0.0027154211420565844, 0.06429700553417206, -0.0080213388428092, -0.028054870665073395, 0.025517214089632034, -0.0874343290925026, 0.02699534222483635, 0.03062129020690918, 0.06055517867207527, 0.08417440950870514, -0.0496967...
9f210cad-040c-40dc-a0a6-a4b059978423
slug: /best-practices/avoid-mutations sidebar_position: 10 sidebar_label: 'Avoid mutations' title: 'Avoid mutations' description: 'Page describing why to avoid mutations in ClickHouse' keywords: ['mutations'] doc_type: 'guide' import Content from '@site/docs/best-practices/_snippets/_avoid_mutations.md';
{"source_file": "avoid_mutations.md"}
[ -0.05297867953777313, 0.0320674367249012, -0.038414519280195236, -0.016234062612056732, 0.06773917376995087, -0.055206723511219025, 0.00197497196495533, 0.026555854827165604, -0.04880748689174652, -0.009904004633426666, 0.07788009196519852, 0.05526478588581085, 0.06321919709444046, -0.0440...
55202a93-6624-4e64-9d91-2916ebc8a3e9
slug: /best-practices/choosing-a-primary-key sidebar_position: 10 sidebar_label: 'Choosing a primary key' title: 'Choosing a Primary Key' description: 'Page describing how to choose a primary key in ClickHouse' keywords: ['primary key'] show_related_blogs: true doc_type: 'guide' import Image from '@theme/IdealImage...
{"source_file": "choosing_a_primary_key.md"}
[ -0.027205072343349457, -0.008050285279750824, -0.05725054442882538, 0.01588236354291439, 0.02024948038160801, -0.03113502264022827, -0.021294519305229187, 0.06556840986013412, 0.045026279985904694, 0.04013705626130104, 0.041586101055145264, 0.1290159523487091, 0.09171102195978165, -0.03567...
5d1c4600-9d6a-4845-85b5-f2259d0035c6
Example {#example} Consider the following posts_unordered table. This contains a row per Stack Overflow post. This table has no primary key - as indicated by ORDER BY tuple() . sql CREATE TABLE posts_unordered ( `Id` Int32, `PostTypeId` Enum('Question' = 1, 'Answer' = 2, 'Wiki' = 3, 'TagWikiExcerpt' = 4, ...
{"source_file": "choosing_a_primary_key.md"}
[ -0.015862461179494858, -0.021116437390446663, -0.041230566799640656, 0.043090805411338806, -0.024810951203107834, -0.052017904818058014, -0.04030382260680199, -0.003739158157259226, 0.03172115609049797, 0.09051136672496796, 0.06141907349228859, -0.001582036493346095, 0.10159394890069962, -...
3166c730-17a9-47db-9611-c0be1dc2e1b8
PostTypeId has a cardinality of 8 and represents the logical choice for the first entry in our ordering key. Recognizing date granularity filtering is likely to be sufficient (it will still benefit datetime filters) so we use toDate(CreationDate) as the 2nd component of our key. This will also produce a smaller inde...
{"source_file": "choosing_a_primary_key.md"}
[ -0.031605314463377, -0.007421466987580061, 0.0769546627998352, 0.06685428321361542, -0.021299438551068306, 0.010855996049940586, -0.00713673559948802, -0.009757333435118198, 0.02468486689031124, -0.020341532304883003, -0.01618300750851631, 0.04388238862156868, 0.01547452062368393, -0.09588...
2d9a8bb5-0ad8-42ac-8779-0fa6adaa92e0
13 rows in set. Elapsed: 0.004 sec. ``` Additionally, we visualize how the sparse index prunes all row blocks that can't possibly contain matches for our example query: :::note All columns in a table will be sorted based on the value of the specified ordering key, regardless of whether they are included in the ke...
{"source_file": "choosing_a_primary_key.md"}
[ -0.039333492517471313, 0.040418412536382675, -0.05832454189658165, -0.014783904887735844, -0.014310196042060852, -0.0009399424307048321, -0.019483795389533043, -0.010289632715284824, 0.054503656923770905, 0.05724869295954704, 0.011575945653021336, 0.08126328140497208, 0.03335125371813774, ...
3affc194-44a1-4c8e-a65e-31ae4e3e31fb
slug: /best-practices/selecting-an-insert-strategy sidebar_position: 10 sidebar_label: 'Selecting an insert strategy' title: 'Selecting an insert strategy' description: 'Page describing how to choose an insert strategy in ClickHouse' keywords: ['INSERT', 'asynchronous inserts', 'compression', 'batch inserts'] show_rela...
{"source_file": "selecting_an_insert_strategy.md"}
[ -0.042565297335386276, -0.0162906926125288, -0.082196444272995, 0.06562990695238113, 0.0097923269495368, -0.02380438521504402, -0.0345786027610302, 0.026836631819605827, -0.07099563628435135, 0.053581204265356064, 0.05164588615298271, 0.055370476096868515, 0.11872082948684692, -0.041018161...
8b51139d-bbcc-4b90-b730-82355a87a9f5
The data is ⑤ transmitted to a ClickHouse network interface—either the native or HTTP interface (which we compare later in this post). Server-side steps {#server-side-steps} After ⑥ receiving the data, ClickHouse ⑦ decompresses it if compression was used, then ⑧ parses it from the originally sent format. Us...
{"source_file": "selecting_an_insert_strategy.md"}
[ -0.05021221563220024, -0.024748705327510834, 0.01114972960203886, 0.04129926487803459, -0.03759145736694336, -0.08698512613773346, -0.03384701907634735, -0.025953684002161026, 0.014198546297848225, 0.03025461733341217, 0.058176737278699875, 0.05864819511771202, 0.05902780219912529, -0.1154...
5c0abfc6-aa87-44c4-8942-c1635eeb80f1
JSONEachRow : Easy to use but expensive to parse. Suitable for low-volume use cases or quick integrations. Use compression {#use-compression} Compression plays a critical role in reducing network overhead, speeding up inserts, and lowering storage costs in ClickHouse. Used effectively, it enhances ingestion perfo...
{"source_file": "selecting_an_insert_strategy.md"}
[ -0.0692194253206253, 0.06472939252853394, -0.0722656100988388, -0.02135910838842392, -0.052702054381370544, -0.06784626096487045, -0.06913480907678604, 0.01741112768650055, 0.014262758195400238, 0.007087529171258211, 0.006894034333527088, 0.057054758071899414, -0.012579387985169888, 0.0354...
757411f7-0171-441b-b673-b170ffeb7f86
Pre-sort if low cost {#pre-sort-if-low-cost} Pre-sorting data by primary key before insertion can improve ingestion efficiency in ClickHouse, particularly for large batches. When data arrives pre-sorted, ClickHouse can skip or simplify the internal sorting step during part creation, reducing CPU usage and accelera...
{"source_file": "selecting_an_insert_strategy.md"}
[ -0.031123671680688858, 0.03188930079340935, 0.023747887462377548, -0.011739387176930904, -0.06678851693868637, 0.014970398508012295, -0.045135874301195145, 0.03598013520240784, 0.056897781789302826, 0.07650357484817505, 0.03918987512588501, 0.13078679144382477, -0.027457136660814285, -0.00...
8e505b5d-ed45-4dc9-b8f2-e8ecf3024e09
However, it lacks the native protocol's deeper integration and cannot perform client-side optimizations like materialized value computation or automatic conversion to Native format. While HTTP inserts can still be compressed using standard HTTP headers (e.g. Content-Encoding: lz4 ), the compression is applied to the e...
{"source_file": "selecting_an_insert_strategy.md"}
[ -0.08379574865102768, 0.06303349882364273, -0.04661174491047859, 0.0010628344025462866, -0.03562048450112343, -0.05434650927782059, -0.11225743591785431, -0.004981532227247953, 0.022288190200924873, 0.04040240868926048, -0.05054819956421852, 0.02380843460559845, 0.020547354593873024, 0.010...
7de33f45-f4e8-4f0b-832d-b6e78b5351f3
slug: /best-practices/use-data-skipping-indices-where-appropriate sidebar_position: 10 sidebar_label: 'Data skipping indices' title: 'Use data skipping indices where appropriate' description: 'Page describing how and when to use data skipping indices' keywords: ['data skipping index', 'skip index'] show_related_blogs: ...
{"source_file": "using_data_skipping_indices.md"}
[ 0.012319398112595081, 0.056772537529468536, 0.013269382528960705, 0.07686308771371841, 0.048083268105983734, -0.034948885440826416, 0.020583977922797203, -0.01502571813762188, -0.028035519644618034, -0.013386215083301067, 0.03847237676382065, 0.09437955170869827, 0.09292159229516983, -0.01...
869b4720-d7e8-4285-a381-ac35a60229b2
tokenbf_v1 / ngrambf_v1 : Specialized Bloom filter variants designed for searching tokens or character sequences in strings — particularly useful for log data or text search use cases. While powerful, skip indexes must be used with care. They only provide benefit when they eliminate a meaningful number of data bloc...
{"source_file": "using_data_skipping_indices.md"}
[ -0.012414109893143177, 0.024664340540766716, 0.019305212423205376, 0.04061475023627281, 0.04439707100391388, -0.013875764794647694, 0.027596967294812202, -0.008529236540198326, 0.044112809002399445, -0.02465178817510605, 0.016825497150421143, 0.01963849738240242, -0.027233004570007324, -0....
88405ac8-31f2-4f02-a8b3-304a267ba270
For a more detailed guide on Data Skipping Indices see here . Example {#example} Consider the following optimized table. This contains Stack Overflow data with a row per post. sql CREATE TABLE stackoverflow.posts ( `Id` Int32 CODEC(Delta(4), ZSTD(1)), `PostTypeId` Enum8('Question' = 1, 'Answer' = 2, 'Wiki' =...
{"source_file": "using_data_skipping_indices.md"}
[ 0.00627964548766613, -0.0067152297124266624, -0.014325716532766819, 0.09772289544343948, -0.006843769922852516, -0.05095652490854263, 0.02275637723505497, -0.014925374649465084, -0.03843541815876961, 0.03569614887237549, 0.08487604558467865, -0.04230760782957077, 0.035146910697221756, -0.0...
235ce5e1-42d3-496c-9782-f59224f8f64c
```sql EXPLAIN indexes = 1 SELECT count() FROM stackoverflow.posts WHERE (CreationDate > '2009-01-01') AND (ViewCount > 10000000) LIMIT 1 ┌─explain──────────────────────────────────────────────────────────┐ │ Expression ((Project names + Projection)) │ │ Limit (preliminary LIMIT (without OFFS...
{"source_file": "using_data_skipping_indices.md"}
[ 0.0020688986405730247, -0.0200921893119812, 0.05188572034239769, 0.06539690494537354, -0.0024732102174311876, 0.02774183079600334, 0.022766223177313805, -0.019542746245861053, -0.010347933508455753, 0.06129372492432594, 0.036230575293302536, -0.06218980997800827, 0.07901317626237869, -0.02...
90331fe0-7e48-4367-829e-4d8fec0745cf
This index could have also been added during initial table creation. The schema with the minmax index defined as part of the DDL: sql CREATE TABLE stackoverflow.posts ( `Id` Int32 CODEC(Delta(4), ZSTD(1)), `PostTypeId` Enum8('Question' = 1, 'Answer' = 2, 'Wiki' = 3, 'TagWikiExcerpt' = 4, 'TagWiki' = 5, 'Moderator...
{"source_file": "using_data_skipping_indices.md"}
[ -0.005375411361455917, -0.03610186278820038, -0.03861131891608238, 0.08138274401426315, -0.010597135871648788, -0.02544785477221012, -0.011694345623254776, 0.026655247434973717, -0.016530653461813927, 0.05039272457361221, 0.06898027658462524, -0.025432754307985306, 0.028962060809135437, -0...
8ac43115-4238-45f7-807c-82d541f17e0e
An EXPLAIN indexes = 1 confirms use of the index. ```sql EXPLAIN indexes = 1 SELECT count() FROM stackoverflow.posts WHERE (CreationDate > '2009-01-01') AND (ViewCount > 10000000) ┌─explain────────────────────────────────────────────────────────────┐ │ Expression ((Project names + Projection)) ...
{"source_file": "using_data_skipping_indices.md"}
[ -0.0015952861867845058, -0.0358237586915493, 0.05213150754570961, 0.09271673858165741, 0.00663627777248621, 0.0341828316450119, 0.023306583985686302, -0.024788957089185715, 0.020640306174755096, 0.049170177429914474, 0.035688795149326324, -0.03400271385908127, 0.07346796989440918, -0.04594...
dfa945d6-77e9-4df7-b9e0-244a5718280a
slug: /best-practices/minimize-optimize-joins sidebar_position: 10 sidebar_label: 'Minimize and optimize JOINs' title: 'Minimize and optimize JOINs' description: 'Page describing best practices for JOINs' keywords: ['JOIN', 'Parallel Hash JOIN'] show_related_blogs: true doc_type: 'guide' import Image from '@theme/I...
{"source_file": "minimize_optimize_joins.md"}
[ -0.0227682963013649, 0.005657868925482035, -0.04073791205883026, 0.05785524845123291, 0.011081499978899956, -0.03675446659326553, -0.03003794699907303, 0.037573155015707016, -0.03725942224264145, -0.009452450089156628, 0.006067299284040928, 0.05162552371621132, 0.07624831795692444, 0.02106...
8bc6656f-098e-4448-9db8-59b46227f2da
Reduce the sizes of JOINed tables : The runtime and memory consumption of JOINs grows proportionally with the sizes of the left and right tables. To reduce the amount of processed data by the JOIN, add additional filter conditions in the WHERE or JOIN ON clauses of the query. ClickHouse pushes filter conditions as ...
{"source_file": "minimize_optimize_joins.md"}
[ -0.005292526446282864, 0.020868616178631783, -0.029873289167881012, 0.028063824400305748, -0.061902012676000595, -0.06515362858772278, -0.001348509336821735, -0.008015069179236889, -0.027897316962480545, -0.02899489365518093, -0.030885357409715652, 0.050991881638765335, 0.05101175233721733, ...
b29c6d1f-9fb3-4e94-8c98-88b55c5787f8
:::note Use dictionaries carefully When using dictionaries for JOINs in ClickHouse, it's important to understand that dictionaries, by design, do not allow duplicate keys. During data loading, any duplicate keys are silently deduplicated—only the last loaded value for a given key is retained. This behavior makes dictio...
{"source_file": "minimize_optimize_joins.md"}
[ -0.04028661176562309, -0.049415674060583115, -0.026080403476953506, -0.019827859476208687, -0.06016158685088158, -0.033727534115314484, 0.036336496472358704, -0.07401296496391296, 0.006135937757790089, -0.007174860220402479, 0.028993045911192894, 0.03301661089062691, 0.075572170317173, 0.0...
70980529-c081-4d45-aaa8-66cd4b764c27
slug: /best-practices keywords: ['Cloud', 'Primary key', 'Ordering key', 'Materialized Views', 'Best Practices', 'Bulk Inserts', 'Asynchronous Inserts', 'Avoid Mutations', 'Avoid nullable Columns', 'Avoid Optimize Final', 'Partitioning Key'] title: 'Overview' hide_title: true description: 'Landing page for Best Practic...
{"source_file": "index.md"}
[ 0.014548268169164658, 0.015029177069664001, -0.008035221137106419, 0.019602585583925247, 0.03946736454963684, -0.014339479617774487, -0.012559651397168636, 0.009596980176866055, -0.08502176403999329, 0.10097550600767136, 0.044873058795928955, 0.059290580451488495, 0.09174201637506485, -0.0...
5c4bb584-5039-49fd-91c1-05b651468449
slug: /best-practices/select-data-types sidebar_position: 10 sidebar_label: 'Selecting data types' title: 'Selecting data types' description: 'Page describing how to choose data types in ClickHouse' keywords: ['data types'] doc_type: 'reference' import NullableColumns from '@site/docs/best-practices/_snippets/_avoi...
{"source_file": "select_data_type.md"}
[ -0.003948734607547522, 0.008316170424222946, -0.06806094199419022, 0.02704126574099064, 0.00010097982158185914, -0.05605313926935196, -0.042765650898218155, 0.02556094154715538, -0.006318378262221813, 0.030775723978877068, 0.012947906740009785, 0.05468827486038208, 0.03966040536761284, -0....
bb4d78a7-c910-471d-8cf8-bc82457f00f5
Enums for data validation: The Enum type can be used to efficiently encode enumerated types. Enums can either be 8 or 16 bits, depending on the number of unique values they are required to store. Consider using this if you need either the associated validation at insert time (undeclared values will be rejected) or wis...
{"source_file": "select_data_type.md"}
[ -0.03392697870731354, -0.06260275840759277, -0.01765456795692444, -0.032226238399744034, -0.0005499336984939873, -0.04679213464260101, 0.009017406031489372, -0.010445228777825832, -0.05132795125246048, -0.0023768674582242966, -0.012121548876166344, -0.08001647144556046, 0.0012449660571292043...
15201b4e-f288-41cf-a95f-e239494faa9f
22 rows in set. Elapsed: 0.130 sec. ``` :::note Note below we use the glob pattern *.parquet to read all files in the stackoverflow/parquet/posts folder. ::: By applying our early simple rules to our posts table, we can identify an optimal type for each column:
{"source_file": "select_data_type.md"}
[ 0.0019494574517011642, 0.0124068483710289, -0.0883110985159874, -0.10452785342931747, -0.049061551690101624, -0.02278020977973938, 0.04314608499407768, 0.014288477599620819, 0.006797218695282936, 0.025538308545947075, 0.01867827959358692, 0.03992354869842529, -0.004239360801875591, -0.0479...
057f0284-01bc-4cbb-a6f5-ff1d0160625c
| Column | Is Numeric | Min, Max | Unique Values | Nulls | Comment | Optimized Type | |------------------------|------------|------...
{"source_file": "select_data_type.md"}
[ 0.02567560225725174, -0.0011926016304641962, -0.06033676862716675, 0.0020764777436852455, -0.09470570832490921, 0.03782108426094055, 0.060976963490247726, 0.025806330144405365, -0.027843007817864418, 0.03445541858673096, 0.0657227635383606, -0.03378608450293541, 0.05902000144124031, -0.045...
839411a0-ee72-4681-91fb-ba0c945dd358
| LastEditorUserId | Yes | -1, 9999993 | 1104694 | Yes | 0 is an unused value can be used for Nulls | Int32 | | LastEditorDisplayName | No |...
{"source_file": "select_data_type.md"}
[ 0.07246224582195282, 0.053261008113622665, -0.04887404665350914, 0.046304717659950256, -0.04050883278250694, 0.04809420183300972, 0.04277205467224121, 0.1012502908706665, 0.016008410602808, -0.025603754445910454, 0.04296072572469711, -0.10865738242864609, 0.03802284225821495, -0.0344740338...
7be14ad0-4e9a-432d-91bc-b2f8bff88019
| ParentId | No | - | 20696028 | Yes | Consider Null to be an empty string | String | | CommunityOwnedDate | No |...
{"source_file": "select_data_type.md"}
[ 0.07706430554389954, 0.07191555202007294, -0.02257552370429039, 0.029711956158280373, -0.06261958181858063, 0.007698889821767807, -0.009800597093999386, 0.08025017380714417, -0.015289925038814545, -0.001012114342302084, 0.10052545368671417, -0.13369879126548767, -0.02058214694261551, -0.05...
0290ee81-b716-4ea2-9a14-7621514b9cfb
:::note Tip Identifying the type for a column relies on understanding its numeric range and number of unique values. To find the range of all columns, and the number of distinct values, users can use the simple query SELECT * APPLY min, * APPLY max, * APPLY uniq FROM table FORMAT Vertical . We recommend performing thi...
{"source_file": "select_data_type.md"}
[ 0.05692516267299652, -0.01787417382001877, -0.04772800952196121, 0.03647730499505997, -0.05878186970949173, 0.007583237253129482, 0.06789073348045349, 0.011418239213526249, -0.025842109695076942, 0.04720934480428696, 0.10160548239946365, -0.05149169638752937, 0.07853856682777405, -0.033823...
c46f3d5a-7a2e-43e0-9eda-5e4bb9d3de25
slug: /best-practices/use-materialized-views sidebar_position: 10 sidebar_label: 'Use materialized views' title: 'Use Materialized Views' description: 'Page describing Materialized Views' keywords: ['materialized views', 'medallion architecture'] show_related_blogs: true doc_type: 'guide' import Image from '@theme/...
{"source_file": "use_materialized_views.md"}
[ -0.09266466647386551, -0.041895247995853424, -0.05808138847351074, 0.027300305664539337, -0.04890763387084007, -0.06074318662285805, -0.05490296706557274, -0.00935611966997385, -0.015075999312102795, 0.030629782006144524, 0.016713183373212814, 0.10760565847158432, 0.044035010039806366, -0....
a772e713-6afe-4c2e-adf7-7f40e91f3ee1
When to use incremental materialized views {#when-to-use-incremental-materialized-views} Incremental materialized views are generally preferred, as they update automatically in real-time whenever the source tables receive new data. They support all aggregation functions and are particularly effective for aggregations...
{"source_file": "use_materialized_views.md"}
[ -0.029512107372283936, -0.05260050669312477, -0.03844645619392395, 0.047255199402570724, -0.009924388490617275, -0.0017761732451617718, -0.042874015867710114, -0.005682786460965872, 0.06258659809827805, 0.024410704150795937, 0.005745923146605492, 0.02010957896709442, 0.011701557785272598, ...
2400d27d-89da-4575-a4fb-626e2190a177
REPLACE is the default behavior. Each time the view is refreshed, the previous contents of the target table are completely overwritten with the latest query result. This is suitable for use cases where the view should always reflect the latest state, such as caching a result set. APPEND , by contrast, allows new row...
{"source_file": "use_materialized_views.md"}
[ -0.044382184743881226, -0.04535149782896042, 0.031584482640028, 0.0339680016040802, -0.0022786851041018963, 0.029470456764101982, -0.037433281540870667, -0.026118312031030655, 0.02224930189549923, 0.06454718112945557, 0.027795542031526566, 0.02848171256482601, 0.013011067174375057, -0.0833...
787a6c7a-0db1-4adb-98a1-684ecd7fa061
slug: /guides/sizing-and-hardware-recommendations sidebar_label: 'Sizing and hardware recommendations' sidebar_position: 4 title: 'Sizing and hardware recommendations' description: 'This guide discusses our general recommendations regarding hardware, compute, memory, and disk configurations for open-source users.' doc_...
{"source_file": "sizing-and-hardware-recommendations.md"}
[ 0.014436524361371994, -0.025029323995113373, 0.010381265543401241, 0.0034637420903891325, -0.04903377592563629, -0.06103525683283806, -0.03487955033779144, 0.05643318220973015, -0.06330393254756927, 0.04446955397725105, -0.022123483940958977, 0.011789037846028805, 0.027686744928359985, -0....
f15dc5c4-be94-4e8f-8b16-a56b3912292a
Data warehousing use case For data warehousing workloads and ad-hoc analytical queries, we recommend the R-type series from AWS or the equivalent offering from your cloud provider as they are memory optimized. What should CPU utilization be? {#what-should-cpu-utilization-be} There is no standard CPU utilizati...
{"source_file": "sizing-and-hardware-recommendations.md"}
[ 0.0024381966795772314, -0.022509027272462845, -0.047940582036972046, 0.04094863682985306, -0.02944285050034523, -0.03446786850690842, 0.06260374188423157, -0.025837428867816925, -0.04525722563266754, 0.011189542710781097, -0.018153071403503418, -0.060260459780693054, 0.0023783205542713404, ...
41fb3c45-ef2e-4384-92f9-4058a6a5663a
ClickHouse does not automatically shard, and re-sharding your dataset will require significant compute resources. Therefore, we generally recommend using the largest server available to prevent having to re-shard your data in the future. Consider using ClickHouse Cloud which scales automatically and allows you to e...
{"source_file": "sizing-and-hardware-recommendations.md"}
[ -0.005654744803905487, -0.03691874444484711, -0.010659468360245228, -0.022889316082000732, -0.07990516722202301, -0.04977010190486908, -0.060220614075660706, -0.011282311752438545, -0.03402582183480263, 0.04267152026295662, -0.03293206915259361, 0.06141405552625656, 0.024331288412213326, -...
18e9e81a-a2d0-49d5-a065-f019c2ebb83a
description: 'Documentation for the HTTP interface in ClickHouse, which provides REST API access to ClickHouse from any platform and programming language' sidebar_label: 'HTTP Interface' sidebar_position: 15 slug: /interfaces/http title: 'HTTP Interface' doc_type: 'reference' import PlayUI from '@site/static/imag...
{"source_file": "http.md"}
[ -0.013305538333952427, -0.02297312393784523, -0.06039637699723244, -0.11419336497783661, -0.07157640159130096, -0.014482775703072548, -0.07545841485261917, 0.011911083944141865, -0.03606916591525078, 0.0028183083049952984, 0.026082051917910576, 0.02571593038737774, -0.00684102438390255, -0...
9ab7d6d6-383a-4f42-aab8-33a79931ff83
In the example below curl is used to send the query SELECT 1 . Note the use of URL encoding for the space: %20 . bash title="command" curl 'http://localhost:8123/?query=SELECT%201' response title="Response" 1 In this example wget is used with the -nv (non-verbose) and -O- parameters to output the result to ...
{"source_file": "http.md"}
[ -0.015564218163490295, 0.04720044136047363, -0.06237102672457695, 0.028055552393198013, -0.07279830425977707, -0.074781633913517, -0.016660692170262337, -0.008365616202354431, 0.08046018332242966, 0.009608539752662182, -0.05986873432993889, -0.0464722216129303, 0.022846871986985207, -0.068...
5a75420f-851a-4de0-a98b-dea78b6c089b
"data": [ { "1": 1, "2": 2, "3": 3 } ], "rows": 1, "statistics": { "elapsed": 0.000515, "rows_read": 1, "bytes_read": 1 } } ``` You can use the default_format URL parameter or the X-ClickHouse-Format header to specify a default format other than TabSeparated . b...
{"source_file": "http.md"}
[ 0.04321284964680672, 0.027629826217889786, -0.06952638924121857, 0.048841774463653564, -0.10746080428361893, -0.04968194290995598, 0.014324870891869068, 0.03532572090625763, -0.03347430378198624, 0.060015998780727386, -0.0358329638838768, -0.0654265359044075, 0.049154311418533325, -0.03616...
41e93be3-32c3-473d-ac0e-5016aa753523
To increase the efficiency of data insertion, disable server-side checksum verification by using the http_native_compression_disable_checksumming_on_decompress setting. If you specify compress=1 in the URL, the server will compress the data it sends to you. If you specify decompress=1 in the URL, the server wil...
{"source_file": "http.md"}
[ -0.08650732040405273, 0.05485256388783455, -0.061313822865486145, 0.007258418947458267, -0.00835657212883234, -0.14055630564689636, -0.07519770413637161, -0.05772833526134491, -0.05225338041782379, 0.006777254864573479, -0.020495295524597168, 0.05493083596229553, 0.0593457855284214, -0.012...
2b3eec10-bc19-494b-bee3-d92d89622252
For example: bash echo 'SELECT 1' | curl 'http://localhost:8123/?user=user&password=password' -d @- Using the 'X-ClickHouse-User' and 'X-ClickHouse-Key' headers For example: bash echo 'SELECT 1' | curl -H 'X-ClickHouse-User: user' -H 'X-ClickHouse-Key: password' 'http://localhost:8123/' -d @- If the user ...
{"source_file": "http.md"}
[ 0.022831643000245094, 0.01421637088060379, -0.12091406434774399, -0.02750774472951889, -0.13237276673316956, -0.05579677224159241, 0.04705898463726044, 0.046834446489810944, -0.002607940463349223, -0.02467181347310543, -0.02536713145673275, -0.04532236605882645, 0.10192219913005829, -0.107...
d8a98846-3887-4c04-bdb4-5629696b2352
The following optional parameters exist: | Parameters | Description | |-----------------------|-------------------------------------------| | query_id (optional) | Can be passed as the query ID (any string). replace_running_query | | quota_key (optional)| Can be passed as...
{"source_file": "http.md"}
[ -0.04483695700764656, 0.03197921812534332, -0.11833003163337708, 0.06417617946863174, -0.07224076986312866, -0.032247550785541534, 0.014327755197882652, 0.07649978995323181, 0.004517476074397564, -0.004611572716385126, -0.05880740284919739, -0.03999898210167885, 0.07773188501596451, -0.062...
49d57fa8-964c-4253-b3ca-5ba287fc21bc
In this case, ?role=my_role&role=my_other_role works similarly to executing SET ROLE my_role, my_other_role before the statement. HTTP response codes caveats {#http_response_codes_caveats} Because of limitations of the HTTP protocol, a HTTP 200 response code does not guarantee that a query was successful. Her...
{"source_file": "http.md"}
[ 0.019969727843999863, 0.050389427691698074, 0.002403988502919674, 0.01228311751037836, -0.03495563194155693, -0.055328648537397385, 0.010210728272795677, 0.024689478799700737, -0.022081945091485977, -0.05007966235280037, 0.004693548660725355, -0.07819701731204987, 0.09862884134054184, -0.0...
cdbb61c8-1524-4062-8226-06b3bb22f4e2
"data": [ { "sleepEachRow(0.001)": 0, "throwIf(equals(number, 2))": 0 }, { "sleepEachRow(0.001)": 0, "throwIf(equals(number, 2))": 0 } exception dmrdfnujjqvszhav Code: 395. DB::Exception: Value passed to 'throwIf' function is non-zero: while executing 'FUNCTION throwI...
{"source_file": "http.md"}
[ 0.04986727982759476, 0.11149758845567703, -0.055715762078762054, 0.00227931491099298, 0.019455142319202423, -0.020719461143016815, 0.014515743590891361, 0.026205560192465782, 0.06487008929252625, 0.043057262897491455, -0.0030424059368669987, -0.12004321813583374, 0.043756064027547836, -0.0...
12a6c405-5c2d-40a5-a63d-e987337bcc1f
bash $ echo '(4),(5),(6)' | curl 'http://localhost:8123/?query=INSERT%20INTO%20t%20VALUES' --data-binary @- ClickHouse also supports a Predefined HTTP Interface which can help you more easily integrate with third-party tools like Prometheus exporter . Let's look at an example. First of all, add this section to you...
{"source_file": "http.md"}
[ -0.017176859080791473, 0.06354020535945892, -0.05277476832270622, -0.007796696852892637, -0.03327254205942154, -0.09718069434165955, -0.009823275730013847, -0.05097853019833565, -0.01012217253446579, 0.003865256905555725, 0.009675140492618084, -0.06937051564455032, 0.03344497084617615, -0....
56056138-ee53-4026-b46f-a050551c243a
- full_url - handler Each of these are discussed below: method is responsible for matching the method part of the HTTP request. method fully conforms to the definition of [ method ] (https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) in the HTTP protocol. It is an optional configuration. If i...
{"source_file": "http.md"}
[ -0.021142853423953056, 0.0631500855088234, -0.0042295074090361595, -0.01547284610569477, -0.006249269004911184, -0.11164231598377228, 0.009542275220155716, -0.019453583285212517, 0.023578006774187088, -0.035877615213394165, 0.019916392862796783, -0.0006487203063443303, 0.003465704619884491, ...
37754237-5a19-47d5-95e8-56032974a7b1
The following example defines the values of max_threads and max_final_threads settings, then queries the system table to check whether these settings were set successfully. :::note To keep the default handlers such as query , play , ping , add the <defaults/> rule. ::: For example: yaml <http_handlers> ...
{"source_file": "http.md"}
[ 0.020066047087311745, -0.007838023826479912, -0.07757449895143509, -0.02749037556350231, -0.09254022687673569, -0.010270008817315102, 0.03910638764500618, 0.010815626941621304, -0.04084259271621704, 0.06342159956693649, -0.004307011608034372, -0.055904582142829895, 0.024068236351013184, -0...
81f995f8-c477-4729-9b67-71fc8c205954
static {#static} static can return content_type , status and response_content . response_content can return the specified content. For example, to return a message "Say Hi!": yaml <http_handlers> <rule> <methods>GET</methods> <headers><XXX>xxx</XXX></headers> <ur...
{"source_file": "http.md"}
[ -0.014934827573597431, 0.06209772825241089, 0.004833870567381382, 0.030537335202097893, 0.010019645094871521, -0.03127099573612213, -0.010508562438189983, -0.0059967958368361, -0.018462957814335823, -0.02122858352959156, -0.0283722672611475, -0.021284835413098335, 0.021923355758190155, 0.0...
d7dec68c-46a9-476c-af41-fcfd37e5a1f8
GET /get_config_static_handler HTTP/1.1 Host: localhost:8123 User-Agent: curl/7.47.0 Accept: / XXX:xxx < HTTP/1.1 200 OK < Date: Wed, 29 Apr 2020 04:01:24 GMT < Connection: Keep-Alive < Content-Type: text/plain; charset=UTF-8 < Transfer-Encoding: chunked < Keep-Alive: timeout=10 < X-ClickHouse-Summary: {"read_rows"...
{"source_file": "http.md"}
[ -0.0036021468695253134, 0.05277867242693901, -0.06973520666360855, -0.008321232162415981, 0.030751653015613556, -0.0909988209605217, -0.010364951565861702, -0.04746898263692856, 0.023530809208750725, 0.05808384716510773, 0.035862796008586884, 0.03500543534755707, -0.020534636452794075, -0....