id
stringlengths
36
36
document
stringlengths
3
3k
metadata
stringlengths
23
69
embeddings
listlengths
384
384
6ab4b0a2-d920-48d4-8d8e-68bff8dc8898
slug: /guides/sre/network-ports sidebar_label: 'Network ports' title: 'Network ports' description: 'Description of available network ports and what they are used for' doc_type: 'reference' keywords: ['network', 'ports', 'configuration', 'security', 'firewall'] Network ports :::note Ports described as default me...
{"source_file": "network-ports.md"}
[ -0.005691055208444595, -0.0381222702562809, -0.046426914632320404, -0.07353614270687103, -0.03845740854740143, -0.004650451708585024, -0.04727115109562874, -0.04417048767209053, -0.029453670606017113, 0.03822170943021774, 0.026042751967906952, 0.04925532266497612, -0.02679388038814068, 0.0...
c2d2387e-06b6-4dd8-9310-f00ffdc9bed3
slug: /guides/sre/configuring-ssl sidebar_label: 'Configuring SSL-TLS' sidebar_position: 20 title: 'Configuring SSL-TLS' description: 'This guide provides simple and minimal settings to configure ClickHouse to use OpenSSL certificates to validate connections.' keywords: ['SSL configuration', 'TLS setup', 'OpenSSL certi...
{"source_file": "configuring-ssl.md"}
[ -0.04086582735180855, 0.03717484325170517, -0.0747305303812027, 0.03383291885256767, 0.013782263733446598, -0.07879621535539627, -0.014738719910383224, -0.0032857449259608984, -0.03971052169799805, -0.05073505640029907, 0.05674717575311661, -0.004576250910758972, 0.11607658863067627, 0.058...
b85e088a-67ef-40ff-82c9-70be02119e00
Verify the contents of the new CA certificate: bash openssl x509 -in marsnet_ca.crt -text Create a certificate request (CSR) and generate a key for each node: bash openssl req -newkey rsa:2048 -nodes -subj "/CN=chnode1" -addext "subjectAltName = DNS:chnode1.marsnet.local,IP:192.168.1.221" -keyou...
{"source_file": "configuring-ssl.md"}
[ 0.022054441273212433, -0.002206619828939438, -0.0579804927110672, -0.022218290716409683, 0.008558492176234722, -0.03821389377117157, -0.04312007129192352, -0.015539812855422497, 0.04794074594974518, 0.035006940364837646, 0.015241310931742191, -0.09848438203334808, 0.08564607053995132, -0.0...
6a7ea96e-f7c7-4f81-84dd-6e3512a006b4
:::note Recommended port is 9281 for ClickHouse Keeper. However, the port is configurable and can be set if this port is in use already by another application in the environment. For a full explanation of all options, visit https://clickhouse.com/docs/operations/clickhouse-keeper/ ::: Add the following inside...
{"source_file": "configuring-ssl.md"}
[ -0.017494438216090202, -0.012882236391305923, -0.10594112426042557, -0.06754334270954132, -0.04018087312579155, -0.07318447530269623, -0.019093524664640427, -0.04856501892209053, -0.025961684063076973, 0.003015986643731594, 0.06455632299184799, 0.03204192966222763, -0.007369540631771088, 0...
99bd307e-6b17-48a2-b96d-f9cfc13f02ca
The following creates a cluster with one shard replica on two servers (one on each node). xml <remote_servers> <cluster_1S_2R> <shard> <replica> <host>chnode1.marsnet.local</host> <port>9440</port> <user>default</user> <password>Cl...
{"source_file": "configuring-ssl.md"}
[ 0.020462555810809135, -0.038111019879579544, -0.054939575493335724, -0.016815241426229477, -0.018375787883996964, -0.06786736845970154, -0.04830622673034668, -0.05219409614801407, -0.02716640569269657, 0.05304340273141861, 0.0553966760635376, -0.07354271411895752, 0.1326245218515396, -0.08...
33693c95-9f3d-4c6a-8ebc-83f7cbf75539
xml <openSSL> <server> <certificateFile>/etc/clickhouse-server/certs/chnode1.crt</certificateFile> <privateKeyFile>/etc/clickhouse-server/certs/chnode1.key</privateKeyFile> <verificationMode>relaxed</verificationMode> <caConfig>/etc/clickhouse-server/certs/marsnet_ca.crt</caConfig> ...
{"source_file": "configuring-ssl.md"}
[ -0.01772184856235981, 0.04814593866467476, -0.07503347843885422, -0.04545004293322563, 0.026720503345131874, -0.11565049737691879, -0.058186911046504974, -0.08930320292711258, 0.04781366139650345, -0.015392754226922989, 0.07402794808149338, -0.04450216516852379, 0.024630524218082428, 0.032...
c5e73c1f-4bc5-4607-b1de-90eac6cd74b3
6. Testing {#6-testing} Start all nodes, one at a time: bash service clickhouse-server start Verify secure ports are up and listening, should look similar to this example on each node: bash root@chnode1:/etc/clickhouse-server# netstat -ano | grep tcp response tcp 0 0 0.0.0.0:...
{"source_file": "configuring-ssl.md"}
[ 0.026217980310320854, -0.03687523305416107, -0.0807238221168518, -0.03653538227081299, 0.010030116885900497, -0.060802143067121506, -0.020564131438732147, -0.08374352008104324, -0.02948683127760887, 0.029790330678224564, -0.013736111111938953, 0.007657236885279417, -0.01784362457692623, -0...
e557e7d2-e6b8-4210-b31b-00bce3f7d003
Send the 4LW commands in the openssl session bash mntr ```response Post-Handshake New Session Ticket arrived: SSL-Session: Protocol : TLSv1.3 ... read R BLOCK zk_version v22.7.3.5-stable-e140b8b5f3a5b660b6b576747063fd040f583cf3 zk_avg_latency 0 # highlight-next-line zk_max_latenc...
{"source_file": "configuring-ssl.md"}
[ -0.020140131935477257, 0.1350858062505722, -0.1032475084066391, 0.016570011153817177, 0.042783647775650024, -0.09167318791151047, -0.017751645296812057, -0.0012379917316138744, 0.049862414598464966, 0.04150751605629921, -0.05070694163441658, -0.059621840715408325, 0.07164572924375534, 0.04...
76f91949-9a3f-4b64-a069-4a071fa5761b
response ┌─id─┬────column1─┬─column2─┐ │ 1 │ 2022-04-01 │ abc │ │ 2 │ 2022-04-02 │ def │ └────┴────────────┴─────────┘ Summary {#summary} This article focused on getting a ClickHouse environment configured with SSL/TLS. The settings will differ for different requirements in production environments; fo...
{"source_file": "configuring-ssl.md"}
[ -0.06438150256872177, 0.013359579257667065, -0.06508748978376389, -0.022619135677814484, -0.10430187731981277, -0.04036460816860199, 0.015340711921453476, -0.05188190937042236, -0.001651165192015469, -0.05131871625781059, 0.03516851365566254, -0.01752813160419464, 0.05870623141527176, 0.00...
79677552-2a09-4747-bd0d-8657465959b6
slug: /security-and-authentication title: 'Security and Authentication' description: 'Landing page for Security and Authentication' doc_type: 'landing-page' keywords: ['security and authentication', 'access control', 'RBAC', 'user management', 'SRE guide'] | Page ...
{"source_file": "index.md"}
[ -0.03845818340778351, 0.02549237385392189, -0.10765707492828369, -0.006053951568901539, 0.004672447685152292, 0.012096346355974674, 0.06003952398896217, -0.020874977111816406, -0.03744080290198326, -0.0212114080786705, 0.036461781710386276, 0.01735484041273594, 0.08968460559844971, -0.0193...
f875af0e-5e47-42ad-8679-73214c0ef116
slug: /guides/sre/scaling-clusters sidebar_label: 'Rebalancing shards' sidebar_position: 20 description: 'ClickHouse does not support automatic shard rebalancing, so we provide some best practices for how to rebalance shards.' title: 'Rebalancing Data' doc_type: 'guide' keywords: ['scaling', 'clusters', 'horizontal sca...
{"source_file": "scaling-clusters.md"}
[ 0.038870371878147125, -0.09602338075637817, -0.0056998105719685555, 0.04170551151037216, -0.04137993976473808, -0.04271595552563667, -0.08408941328525543, -0.01195767242461443, -0.026213999837636948, 0.03603217378258705, -0.003129939315840602, 0.04206134378910065, 0.050187453627586365, -0....
c9ca9d48-377f-4cb1-ba09-793429dfe122
sidebar_label: 'Primary indexes' sidebar_position: 1 description: 'In this guide we are going to do a deep dive into ClickHouse indexing.' title: 'A Practical Introduction to Primary Indexes in ClickHouse' slug: /guides/best-practices/sparse-primary-indexes show_related_blogs: true doc_type: 'guide' keywords: ['primary...
{"source_file": "sparse-primary-indexes.md"}
[ 0.0019751698710024357, -0.004169275518506765, -0.0326056145131588, 0.06522678583860397, 0.010766949504613876, -0.0039132144302129745, -0.0028915535658597946, 0.0016766581684350967, -0.08105399459600449, 0.011806457303464413, 0.000276321719866246, 0.07902000844478607, 0.031375642865896225, ...
f3d46a99-36b7-4d96-aa98-a8885bb93301
import sparsePrimaryIndexes01 from '@site/static/images/guides/best-practices/sparse-primary-indexes-01.png'; import sparsePrimaryIndexes02 from '@site/static/images/guides/best-practices/sparse-primary-indexes-02.png'; import sparsePrimaryIndexes03a from '@site/static/images/guides/best-practices/sparse-primary-indexe...
{"source_file": "sparse-primary-indexes.md"}
[ -0.020824622362852097, 0.005874363239854574, -0.008463561534881592, -0.0005349886487238109, 0.05472714081406593, -0.09356056898832321, -0.026762256398797035, 0.08493663370609283, -0.06779446452856064, -0.001362198730930686, 0.05863413214683533, 0.05788011848926544, 0.08421875536441803, 0.0...
2498275d-e4a3-40a4-aec9-2fc13a1708b9
A practical introduction to primary indexes in ClickHouse Introduction {#introduction} In this guide we are going to do a deep dive into ClickHouse indexing. We will illustrate and discuss in detail: - how indexing in ClickHouse is different from traditional relational database management systems - how ClickHous...
{"source_file": "sparse-primary-indexes.md"}
[ -0.00441155768930912, -0.04324952885508537, -0.012373872101306915, 0.02876058965921402, -0.03229628503322601, -0.04516781494021416, 0.08506372570991516, -0.026914065703749657, -0.03175165131688118, -0.013056918047368526, 0.010812497697770596, 0.004768943879753351, 0.025012822821736336, -0....
8f6e6a6b-773c-4e4b-acec-6c8f35ccba74
sql INSERT INTO hits_NoPrimaryKey SELECT intHash32(UserID) AS UserID, URL, EventTime
{"source_file": "sparse-primary-indexes.md"}
[ 0.09057554602622986, -0.02524789422750473, -0.03089599683880806, 0.010547135956585407, -0.08175332099199295, 0.006284271366894245, 0.07712820917367935, 0.053295034915208817, 0.03339027613401413, 0.03232809901237488, 0.017719725146889687, -0.071123868227005, 0.06953337788581848, -0.06715510...
c54aa3de-0172-469e-ad1b-3ba4206258a3
URL, EventTime FROM url('https://datasets.clickhouse.com/hits/tsv/hits_v1.tsv.xz', 'TSV', 'WatchID UInt64, JavaEnable UInt8, Title String, GoodEvent Int16, EventTime DateTime, EventDate Date, CounterID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RegionID UInt32, UserID UInt64, CounterClass Int8, ...
{"source_file": "sparse-primary-indexes.md"}
[ -0.02053631842136383, 0.025427594780921936, -0.05260937660932541, -0.02791542001068592, -0.03164270892739296, -0.005069846753031015, 0.016173189505934715, 0.006853423546999693, 0.01912057213485241, 0.01161902118474245, -0.016892213374376297, -0.043817732483148575, -0.034272149205207825, -0...
b0fb2b92-cc5b-44f5-b3c1-fe8e00eb466b
The response is: ```response Ok. 0 rows in set. Elapsed: 145.993 sec. Processed 8.87 million rows, 18.40 GB (60.78 thousand rows/s., 126.06 MB/s.) ``` ClickHouse client's result output shows us that the statement above inserted 8.87 million rows into the table. Lastly, in order to simplify the discussions later o...
{"source_file": "sparse-primary-indexes.md"}
[ -0.004325896967202425, 0.017210662364959717, -0.05064507573843002, 0.07637381553649902, -0.05972222983837128, -0.09010137617588043, 0.06521986424922943, 0.04415563866496086, 0.00831539835780859, 0.07192867249250412, 0.04063820466399193, -0.013566849753260612, 0.08486825227737427, -0.081972...
18f00bf2-469f-4da3-93cc-0bd95c7e6b64
ClickHouse index design {#clickhouse-index-design} An index design for massive data scales {#an-index-design-for-massive-data-scales} In traditional relational database management systems, the primary index would contain one entry per table row. This would result in the primary index containing 8.87 million entries...
{"source_file": "sparse-primary-indexes.md"}
[ 0.01740027777850628, -0.021225905045866966, -0.022403297945857048, 0.03630664199590683, -0.009130147285759449, -0.06325675547122955, -0.033943794667720795, 0.032099418342113495, 0.08374184370040894, 0.059264834970235825, -0.056269820779561996, 0.02169719710946083, 0.010804112069308758, -0....
830ae32b-1807-468c-8526-cc4ecf39addb
The following illustrates in detail how ClickHouse is building and using its sparse primary index. Later on in the article, we will discuss some best practices for choosing, removing, and ordering the table columns that are used to build the index (primary key columns). A table with a primary key {#a-table-with-a-pri...
{"source_file": "sparse-primary-indexes.md"}
[ 0.02004818432033062, -0.022077739238739014, 0.0026327017694711685, 0.007364329416304827, -0.04190598055720329, -0.05920262262225151, -0.0000046221393859013915, 0.004810916259884834, -0.008915857411921024, 0.0224621444940567, -0.01531343162059784, 0.030692484229803085, 0.010716482065618038, ...
9c63cd49-6615-4392-a448-6e3315c9185b
sql INSERT INTO hits_UserID_URL SELECT intHash32(UserID) AS UserID, URL, EventTime
{"source_file": "sparse-primary-indexes.md"}
[ 0.07283546030521393, -0.025776691734790802, -0.003782623913139105, 0.007967323996126652, -0.09595434367656708, 0.004049547947943211, 0.05368449538946152, 0.037495702505111694, 0.013389994390308857, 0.009684324264526367, -0.0313720628619194, -0.066826231777668, 0.049880579113960266, -0.0488...
e0436b57-4d5b-4811-b602-0fbcbb227e1c
URL, EventTime FROM url('https://datasets.clickhouse.com/hits/tsv/hits_v1.tsv.xz', 'TSV', 'WatchID UInt64, JavaEnable UInt8, Title String, GoodEvent Int16, EventTime DateTime, EventDate Date, CounterID UInt32, ClientIP UInt32, ClientIP6 FixedString(16), RegionID UInt32, UserID UInt64, CounterClass Int8, ...
{"source_file": "sparse-primary-indexes.md"}
[ -0.02053631842136383, 0.025427594780921936, -0.05260937660932541, -0.02791542001068592, -0.03164270892739296, -0.005069846753031015, 0.016173189505934715, 0.006853423546999693, 0.01912057213485241, 0.01161902118474245, -0.016892213374376297, -0.043817732483148575, -0.034272149205207825, -0...
49e2d1f0-bfcc-4342-8145-8c78b395616e
The response looks like: response 0 rows in set. Elapsed: 149.432 sec. Processed 8.87 million rows, 18.40 GB (59.38 thousand rows/s., 123.16 MB/s.) And optimize the table: sql OPTIMIZE TABLE hits_UserID_URL FINAL; We can use the following query to obtain metadata about our table: sql SELECT part_type, ...
{"source_file": "sparse-primary-indexes.md"}
[ 0.06532230228185654, 0.06368128210306168, -0.08179998397827148, 0.06473889201879501, -0.022877385839819908, -0.10917222499847412, 0.027098873630166054, 0.07880228757858276, -0.02431255392730236, 0.06001274660229683, -0.020516416057944298, -0.009251775220036507, 0.06971833109855652, -0.0656...
c1e5a186-2565-44da-80bc-d75a10076bdc
The inserted rows are stored on disk in lexicographical order (ascending) by the primary key columns (and the additional EventTime column from the sorting key). :::note ClickHouse allows inserting multiple rows with identical primary key column values. In this case (see row 1 and row 2 in the diagram below), the fi...
{"source_file": "sparse-primary-indexes.md"}
[ -0.0069785150699317455, -0.023541927337646484, -0.1073489859700203, -0.004244364798069, -0.018079906702041626, -0.0416116900742054, 0.03963306546211243, -0.015869125723838806, 0.09452589601278305, 0.09865570813417435, 0.05829779431223869, 0.09399856626987457, 0.06560903042554855, -0.088501...
e6f69b11-e022-4009-b1b5-ff0998ba2458
Therefore all granules (except the last one) of our example table have the same size. For tables with adaptive index granularity (index granularity is adaptive by default the size of some granules can be less than 8192 rows depending on the row data sizes. We marked some column values from our primary key...
{"source_file": "sparse-primary-indexes.md"}
[ 0.02235247753560543, 0.011417318135499954, -0.02705838717520237, 0.0010805854108184576, -0.010078120045363903, -0.08375565707683563, 0.08035522699356079, -0.003898417577147484, 0.04733947291970253, -0.04585561156272888, -0.04426591098308563, 0.020841864868998528, 0.05594908446073532, -0.05...
64af6093-3bf6-4142-ac95-dc722bf1ed4f
returns `/Users/tomschreiber/Clickhouse/store/85f/85f4ee68-6e28-4f08-98b1-7d8affa1d88c/all_1_9_4` on the test machine. Step 2: Get user_files_path The default user_files_path on Linux is `/var/lib/clickhouse/user_files/` and on Linux you can check if it got changed: `$ grep user_files_path /etc/clickhouse-server/...
{"source_file": "sparse-primary-indexes.md"}
[ 0.011401180177927017, -0.03652948886156082, -0.05230403319001198, -0.047578662633895874, 0.025455331429839134, -0.07811136543750763, 0.040234412997961044, 0.010661173611879349, -0.02516311965882778, -0.03124529868364334, 0.13171429932117462, -0.036142412573099136, -0.01601085253059864, -0....
077fc1b1-9eaa-4e78-a9ac-eb6c3d3c7071
We will discuss the consequences of this on query execution performance in more detail later. The primary index is used for selecting granules {#the-primary-index-is-used-for-selecting-granules} We can now execute our queries with support from the primary index. The following calculates the top 10 most clicked ur...
{"source_file": "sparse-primary-indexes.md"}
[ -0.027841638773679733, -0.053754210472106934, -0.008958155289292336, 0.036776985973119736, -0.012388390488922596, -0.04028112441301346, 0.047095075249671936, 0.03910674899816513, 0.05592867359519005, -0.0156857967376709, -0.04896179586648941, 0.01689971424639225, 0.041329074651002884, -0.0...
9dd0e070-31fd-4ea5-a83c-8593a45d6df6
sql EXPLAIN indexes = 1 SELECT URL, count(URL) AS Count FROM hits_UserID_URL WHERE UserID = 749927693 GROUP BY URL ORDER BY Count DESC LIMIT 10; The response looks like: ```response ┌─explain───────────────────────────────────────────────────────────────────────────────┐ │ Expression (Projection) ...
{"source_file": "sparse-primary-indexes.md"}
[ 0.0077803898602724075, 0.0016711781499907374, 0.026708455756306648, 0.05453414469957352, -0.029243677854537964, -0.059992145746946335, 0.09927738457918167, 0.00044174690265208483, 0.061617180705070496, 0.02615431137382984, 0.017403321340680122, -0.023168915882706642, 0.10277226567268372, -...
8d6fed56-574f-46b1-83b0-866c562b19c2
Mark files are used for locating granules {#mark-files-are-used-for-locating-granules} The following diagram illustrates a part of the primary index file for our table. As discussed above, via a binary search over the index's 1083 UserID marks, mark 176 was identified. Its corresponding granule 176 can therefore ...
{"source_file": "sparse-primary-indexes.md"}
[ 0.014697262085974216, 0.010525993071496487, -0.05155588313937187, -0.03604493662714958, 0.027864858508110046, -0.054514605551958084, 0.1076476126909256, 0.03697482496500015, -0.00005664554191753268, -0.035401612520217896, -0.03028189204633236, -0.02357795648276806, 0.08990738540887833, -0....
7d532e55-79b6-4ba8-9ef5-7624c43cec8b
Index granularity is adaptive by default , but for our example table we disabled adaptive index granularity (in order to simplify the discussions in this guide, as well as make the diagrams and results reproducible). Our table is using wide format because the size of the data is larger than min_bytes_for_wide_part (...
{"source_file": "sparse-primary-indexes.md"}
[ 0.014780945144593716, -0.0026188676711171865, 0.002962471218779683, 0.05079694837331772, 0.04865778982639313, -0.07297579944133759, -0.009711714461445808, 0.031231965869665146, -0.012763004750013351, -0.01780475303530693, -0.0517578125, 0.03739646449685097, 0.03439712151885033, -0.04999159...
46c48096-37fc-44d8-b375-a689c891984f
Once the located file block is uncompressed into the main memory, the second offset from the mark file can be used to locate granule 176 within the uncompressed data. ClickHouse needs to locate (and stream all values from) granule 176 from both the UserID.bin data file and the URL.bin data file in order to execute ou...
{"source_file": "sparse-primary-indexes.md"}
[ 0.03397727012634277, 0.012840122915804386, -0.0565822459757328, -0.03134375438094139, -0.0508560873568058, -0.055484455078840256, -0.00437266705557704, 0.026139704510569572, -0.04277731105685234, -0.016304848715662956, -0.011362336575984955, 0.012970540672540665, 0.05626562982797623, -0.09...
56491245-07fb-42be-bd21-1fb2669d3bdc
If trace_logging is enabled then the ClickHouse server log file shows that ClickHouse used a generic exclusion search over the 1083 URL index marks in order to identify those granules that possibly can contain rows with a URL column value of "http://public_search": ```response ...Executor): Key condition: (column 1...
{"source_file": "sparse-primary-indexes.md"}
[ -0.012739456258714199, -0.01046308595687151, -0.018568193539977074, -0.0024677226319909096, 0.06973129510879517, -0.0952124074101448, 0.018075089901685715, -0.04727338254451752, 0.022037014365196228, -0.009510433301329613, 0.012075353413820267, 0.0003959527239203453, 0.022567670792341232, ...
935dd46e-8b44-4e46-9e62-9c438c68fbc8
We have marked the key column values for the first table rows for each granule in orange in the diagrams below.. Predecessor key column has low(er) cardinality Suppose UserID had low cardinality. In this case it would be likely that the same UserID value is spread over multiple table rows and granules and therefore...
{"source_file": "sparse-primary-indexes.md"}
[ 0.023109300062060356, 0.04151662066578865, 0.0582556426525116, -0.05380697920918465, 0.03200879693031311, -0.055138859897851944, 0.07167350500822067, -0.03403666242957115, 0.0420549251139164, -0.06457088887691498, -0.03651554882526398, -0.005000247620046139, 0.062105245888233185, -0.058056...
608ed059-bedd-4c00-b1a3-c5ae1f324f5d
The same scenario is true for mark 1, 2, and 3. :::note Conclusion The generic exclusion search algorithm that ClickHouse is using instead of the binary search algorithm when a query is filtering on a column that is part of a compound key, but is not the first key column is most effective when the predecessor key...
{"source_file": "sparse-primary-indexes.md"}
[ 0.0073634665459394455, 0.006020834669470787, 0.030052954331040382, -0.03572671487927437, -0.0013561546802520752, -0.02888789400458336, -0.004604673013091087, -0.04949820414185524, 0.01917850412428379, -0.035464417189359665, 0.03074072301387787, -0.0024194384459406137, 0.0779963880777359, -...
f68a1a18-831a-4904-b2ff-c236f718d647
The following is showing ways for achieving that. Options for creating additional primary indexes {#options-for-creating-additional-primary-indexes} If we want to significantly speed up both of our sample queries - the one that filters for rows with a specific UserID and the one that filters for rows with a spec...
{"source_file": "sparse-primary-indexes.md"}
[ -0.05163013935089111, -0.059596139937639236, -0.021310955286026, 0.033722735941410065, -0.04205898568034172, 0.007440801244229078, -0.030228089541196823, -0.05649353191256523, 0.026638485491275787, 0.05002472549676895, -0.012760799378156662, -0.001524728606455028, 0.024107785895466805, -0....
4a842322-b590-4bc0-bf02-e2fd629f3d1c
This is the resulting primary key: That can now be used to significantly speed up the execution of our example query filtering on the URL column in order to calculate the top 10 users that most frequently clicked on the URL "http://public_search": sql SELECT UserID, count(UserID) AS Count -- highlight-next-line FR...
{"source_file": "sparse-primary-indexes.md"}
[ -0.02088981866836548, -0.03061932884156704, -0.01692681945860386, 0.01208643801510334, -0.008208436891436577, -0.03429915010929108, 0.04967130720615387, 0.02212824672460556, 0.019640913233160973, 0.019988419488072395, 0.005768093280494213, -0.011178361251950264, 0.05925821512937546, -0.140...
a7ca7a88-2237-4243-b7a5-b9627ef213d5
```sql SELECT URL, count(URL) AS Count FROM hits_URL_UserID WHERE UserID = 749927693 GROUP BY URL ORDER BY Count DESC LIMIT 10; ``` The response is: ```response ┌─URL────────────────────────────┬─Count─┐ │ http://auto.ru/chatay-barana.. │ 170 │ │ http://auto.ru/chatay-id=371...│ 52 │ │ http://public_search ...
{"source_file": "sparse-primary-indexes.md"}
[ 0.006926789414137602, -0.069351427257061, -0.004720146302133799, 0.044627320021390915, -0.06225857883691788, 0.005121893715113401, 0.05564277991652489, 0.005847528111189604, 0.08616098016500473, 0.025562407448887825, 0.021788090467453003, -0.03715805336833, 0.04239259287714958, -0.04762871...
b92ec92c-d7ab-4d39-bcc4-2a57358b807f
ClickHouse is storing the column data files ( .bin), the mark files ( .mrk2) and the primary index (primary.idx) of the implicitly created table in a special folder withing the ClickHouse server's data directory: ::: The implicitly created table (and its primary index) backing the materialized view can now ...
{"source_file": "sparse-primary-indexes.md"}
[ -0.029493117704987526, -0.048094913363456726, -0.0677509754896164, 0.0764976367354393, -0.009057816118001938, -0.06413411349058151, -0.0057091559283435345, -0.062327489256858826, 0.02951662428677082, 0.026606254279613495, 0.08250133693218231, 0.008761530742049217, 0.0484071783721447, -0.10...
ab86f870-856f-4246-bd6c-efaad35d02cb
- if new rows are inserted into the source table hits_UserID_URL, then that rows are automatically also inserted into the hidden table - a query is always (syntactically) targeting the source table hits_UserID_URL, but if the row order and primary index of the hidden table allows a more effective query execution, then ...
{"source_file": "sparse-primary-indexes.md"}
[ -0.10682723671197891, 0.009819621220231056, -0.06612306088209152, 0.06385249644517899, 0.04092962294816971, -0.02276666648685932, 0.014469574205577374, -0.062201447784900665, 0.06444935500621796, 0.05374510586261749, 0.05740398168563843, 0.046132124960422516, 0.09257817268371582, -0.129435...
86ebfcf0-8725-4f03-b7f7-e6b7c7a7b1c6
highlight-next-line 39/1083 marks by primary key, 39 marks to read from 1 ranges ...Executor): Reading approx. 319488 rows with 2 streams ``` Summary {#summary} The primary index of our table with compound primary key (UserID, URL) was very useful for speeding up a query filtering on UserID . But ...
{"source_file": "sparse-primary-indexes.md"}
[ 0.013201690278947353, 0.054666224867105484, 0.005498996004462242, -0.030469216406345367, 0.023116478696465492, -0.032277513295412064, -0.005489179864525795, -0.028739910572767258, 0.07653304189443588, -0.05216321349143982, -0.018407069146633148, -0.014399277977645397, -0.01800471916794777, ...
9e419f03-37f7-4605-8021-93c405311a25
sql SELECT formatReadableQuantity(uniq(URL)) AS cardinality_URL, formatReadableQuantity(uniq(UserID)) AS cardinality_UserID, formatReadableQuantity(uniq(IsRobot)) AS cardinality_IsRobot FROM ( SELECT c11::UInt64 AS UserID, c15::String AS URL, c20::UInt8 AS IsRobot FROM url('h...
{"source_file": "sparse-primary-indexes.md"}
[ 0.05901200696825981, -0.0388614796102047, -0.051519546657800674, 0.04765577241778374, -0.07897619158029556, -0.05656718462705612, -0.022247519344091415, 0.03423338383436203, 0.042725395411252975, 0.06726779043674469, 0.0003485116467345506, -0.02823810838162899, 0.04594673961400986, -0.0849...
9bbd77e1-a0a3-473f-b0d0-cc098108e237
The response is: response 0 rows in set. Elapsed: 95.959 sec. Processed 8.87 million rows, 15.88 GB (92.48 thousand rows/s., 165.50 MB/s.) Efficient filtering on secondary key columns {#efficient-filtering-on-secondary-key-columns} When a query is filtering on at least one column that is part of a compound key, an...
{"source_file": "sparse-primary-indexes.md"}
[ 0.01939740590751171, 0.020108165219426155, -0.05339557304978371, 0.004213368520140648, 0.031496401876211166, -0.10974746942520142, 0.004269157070666552, -0.022924037650227547, 0.023519165813922882, -0.00965241901576519, 0.0341007336974144, 0.014788530766963959, 0.059924278408288956, -0.143...
434c7d9f-5abb-447e-80ce-cc2ec8ac0577
This is the response: ```response ┌─Table───────────────────┬─Column─┬─Uncompressed─┬─Compressed─┬─Ratio─┐ │ hits_URL_UserID_IsRobot │ UserID │ 33.83 MiB │ 11.24 MiB │ 3 │ │ hits_IsRobot_UserID_URL │ UserID │ 33.83 MiB │ 877.47 KiB │ 39 │ └─────────────────────────┴────────┴──────────────┴────────────┴───...
{"source_file": "sparse-primary-indexes.md"}
[ -0.002390448236837983, -0.011070813052356243, -0.0842941477894783, 0.01933257095515728, 0.011615459807217121, -0.11397822201251984, -0.08145976066589355, 0.04141684249043465, 0.02769809402525425, 0.07532712817192078, 0.007752840872853994, 0.025656649842858315, 0.060360100120306015, -0.0850...
64f4ba23-dbbd-4940-97e8-790b8ed4c02d
In contrast to the diagram above, the diagram below sketches the on-disk order of rows for a primary key where the key columns are ordered by cardinality in descending order: Now the table's rows are first ordered by their ch value, and rows that have the same ch value are ordered by their cl value. But becau...
{"source_file": "sparse-primary-indexes.md"}
[ -0.026744650676846504, 0.028801489621400833, -0.012662135995924473, -0.06312308460474014, 0.06815672665834427, -0.06363561004400253, -0.005194548051804304, -0.04676690697669983, 0.1069045439362526, 0.005357626359909773, -0.009551932103931904, 0.07424408942461014, 0.058012738823890686, -0.1...
66484742-182d-4923-af4b-5c42f3fdca93
Because the hash column is used as the primary key column - specific rows can be retrieved very quickly , but - the table's rows (their column data) are stored on disk ordered ascending by (the unique and random) hash values. Therefore also the content column's values are stored in random order with no data locality...
{"source_file": "sparse-primary-indexes.md"}
[ -0.018135488033294678, 0.04287270829081535, -0.03045014850795269, -0.07142333686351776, 0.06279915571212769, -0.00863632746040821, -0.04980448633432388, -0.010556291788816452, 0.1607295125722885, 0.0754794180393219, 0.031031982973217964, 0.1227181926369667, -0.029498113319277763, -0.053373...
f6b82554-d4e9-46b6-abe9-b5594059a7ed
slug: /optimize/query-optimization sidebar_label: 'Query optimization' title: 'Guide for Query optimization' description: 'A simple guide for query optimization that describe common path to improve query performance' doc_type: 'guide' keywords: ['query optimization', 'performance', 'best practices', 'query tuning', 'ef...
{"source_file": "query-optimization.md"}
[ 0.02488396316766739, 0.04571940377354622, -0.04978534206748009, 0.06089426577091217, -0.027385815978050232, -0.07798305153846741, 0.014665466733276844, 0.04426310956478119, -0.09905830770730972, -0.026751792058348656, -0.014146034605801105, 0.039541710168123245, 0.09834425896406174, -0.026...
e01e343f-e7a7-42e0-8fe5-069558052c6c
With this high-level understanding, let's examine the tooling ClickHouse provides and how we can use it to track the metrics that affect query performance.  Dataset {#dataset} We'll use a real example to illustrate how we approach query performances.  Let's use the NYC Taxi dataset, which contains taxi ride data ...
{"source_file": "query-optimization.md"}
[ 0.025845475494861603, -0.08144160360097885, -0.04485420510172844, 0.02825569175183773, -0.01411157101392746, -0.012888059951364994, 0.018985562026500702, -0.039843227714300156, 0.00683348486199975, 0.032594967633485794, 0.02465861476957798, -0.04896058887243271, 0.05616122856736183, -0.081...
bf85a288-1fa9-4079-8b74-de41222f5f1c
Query id: e3d48c9f-32bb-49a4-8303-080f59ed1835 Row 1: ────── type: QueryFinish event_time: 2024-11-27 11:12:36 query_duration_ms: 2967 query: WITH dateDiff('s', pickup_datetime, dropoff_datetime) as trip_time, trip_distance / trip_time * 3600 AS speed_mph SELECT quantiles(0.5, 0....
{"source_file": "query-optimization.md"}
[ 0.040814634412527084, 0.04668862372636795, 0.005373885855078697, 0.09005189687013626, -0.056419629603624344, -0.020528597757220268, 0.037294913083314896, 0.012289985083043575, -0.0146331787109375, -0.01676803268492222, 0.0499059222638607, -0.11720075458288193, -0.05616014823317528, 0.01047...
7de94426-41f5-4254-a367-3dc914c7f296
You might also want to know which queries are stressing the system by examining the query that consumes the most memory or CPU.  sql -- Top queries by memory usage SELECT type, event_time, query_id, formatReadableSize(memory_usage) AS memory, ProfileEvents.Values[indexOf(ProfileEvents.Names, 'User...
{"source_file": "query-optimization.md"}
[ 0.14532186090946198, -0.05238448455929756, -0.08979310095310211, 0.10538600385189056, 0.011882473714649677, -0.09340005367994308, 0.12720459699630737, 0.050568025559186935, -0.06452964246273041, 0.014999938197433949, -0.06601210683584213, -0.038337960839271545, -0.024973852559924126, -0.05...
94c4145f-f7c8-4af3-8ff5-8fc613e4466c
Let's understand a bit better what the queries achieve.  Query 1 calculates the distance distribution in rides with an average speed of over 30 miles per hour. Query 2 finds the number and average cost of rides per week.  Query 3 calculates the average time of each trip in the dataset. None of these queries...
{"source_file": "query-optimization.md"}
[ 0.07625853270292282, -0.05557221546769142, 0.002533514052629471, 0.11450717598199844, -0.04621712118387222, -0.08205554634332657, 0.0641016736626625, 0.003925584256649017, -0.0009239829960279167, 0.003548053791746497, -0.004444189369678497, -0.022806700319051743, 0.021729685366153717, -0.0...
8a97aacb-38a6-45b2-95c3-55409d6576ce
The output is straightforward. The query begins by reading data from the nyc_taxi.trips_small_inferred table. Then, the WHERE clause is applied to filter rows based on computed values. The filtered data is prepared for aggregation, and the quantiles are computed. Finally, the result is sorted and outputted.  Here, ...
{"source_file": "query-optimization.md"}
[ 0.0038478069473057985, 0.030322711914777756, 0.029216770082712173, 0.06787716597318649, -0.036621276289224625, -0.054426614195108414, 0.028405984863638878, 0.02529955469071865, -0.02733226865530014, -0.0007889700937084854, 0.013667809776961803, -0.06682276725769043, -0.04356928914785385, -...
b272c885-3f55-4dc2-ac53-498e14db3cc1
It can be difficult to identify problematic queries on a production deployment, as there are probably a large number of queries being executed at any given time on your ClickHouse deployment.  If you know which user, database, or tables are having issues, you can use the fields user , tables , or databases from t...
{"source_file": "query-optimization.md"}
[ 0.04337030276656151, -0.012468650005757809, 0.025230590254068375, 0.05416853353381157, -0.03591779246926308, -0.13348081707954407, -0.00776388356462121, -0.008945133537054062, -0.07687045633792877, 0.020184926688671112, -0.024337884038686752, -0.02589353173971176, 0.010143850930035114, -0....
1ff0f03f-7b43-4801-8d5f-823f1eee0be2
Running an SQL query that counts the rows with a NULL value can easily reveal the columns in your tables that actually need a Nullable value. ```sql -- Find non-null values columns SELECT countIf(vendor_id IS NULL) AS vendor_id_nulls, countIf(pickup_datetime IS NULL) AS pickup_datetime_nulls, countIf(drop...
{"source_file": "query-optimization.md"}
[ 0.08875182271003723, -0.010801929980516434, -0.029795655980706215, 0.040826186537742615, -0.057682622224092484, 0.05025152117013931, 0.001948581077158451, 0.01000511646270752, -0.027704400941729546, -0.0014276914298534393, 0.08022065460681915, -0.15124790370464325, 0.031104259192943573, -0...
aa12b2cc-a5b4-4b59-a8e3-64b0a8d2c3b2
Clickhouse supports a large number of data types. Make sure to pick the smallest possible data type that fits your use case to optimize performance and reduce your data storage space on disk.  For numbers, you can check the min/max value in your dataset to check if the current precision value matches the reality of y...
{"source_file": "query-optimization.md"}
[ 0.0768590122461319, -0.025170933455228806, -0.01472439430654049, 0.037111420184373856, -0.09682539105415344, -0.024415956810116768, 0.009890963323414326, 0.009707081131637096, -0.06555133312940598, 0.024107426404953003, 0.03855302557349205, -0.04299546778202057, -0.0037761928979307413, -0....
214395ae-b21c-4fef-9357-c6f3234b4fc9
Query id: 72b5eb1c-ff33-4fdb-9d29-dd076ac6f532 ┌─table────────────────┬─compressed─┬─uncompressed─┬──────rows─┐ 1. │ trips_small_inferred │ 7.38 GiB │ 37.41 GiB │ 329044175 │ 2. │ trips_small_no_pk │ 4.89 GiB │ 15.31 GiB │ 329044175 │ └──────────────────────┴────────────┴──────────────┴───────────┘ ``...
{"source_file": "query-optimization.md"}
[ -0.013803026638925076, -0.022524699568748474, -0.05866090953350067, -0.00993155874311924, 0.0011443094117566943, -0.05440274253487587, 0.02310275472700596, 0.011741796508431435, 0.05413685366511345, 0.05692434683442116, 0.004005866125226021, 0.035522110760211945, 0.035821475088596344, -0.0...
f3139d4f-1762-417f-84a5-3d8b22e48e1f
Create a new table with the primary keys and re-ingest the data. ``sql CREATE TABLE trips_small_pk ( vendor_id UInt8, pickup_datetime DateTime, dropoff_datetime DateTime, passenger_count UInt8, trip_distance Float32, ratecode_id LowCardinality(String), pickup_location_id UInt16, dropoff_location_id UInt16, payment_ty...
{"source_file": "query-optimization.md"}
[ 0.03726192191243172, 0.023763995617628098, -0.031232217326760292, 0.07249590754508972, -0.07684491574764252, -0.04415913298726082, 0.01521464716643095, 0.05180246755480766, -0.0038033537566661835, 0.015381445176899433, 0.06088060885667801, -0.06623311340808868, 0.008715006522834301, -0.057...
192059a6-3178-4be2-af74-c3cd898d7e7d
│ Expression │ │ ReadFromMergeTree (nyc_taxi.trips_small_pk) │ │ Indexes: ...
{"source_file": "query-optimization.md"}
[ 0.06682773679494858, -0.00397516880184412, 0.05150473117828369, 0.07496041804552078, 0.014792193658649921, -0.043354570865631104, 0.07764651626348495, -0.01001440454274416, -0.046040695160627365, -0.01783520169556141, 0.003642478957772255, -0.022644469514489174, -0.039036594331264496, -0.0...
64691cf0-c3ae-4337-b21a-c4120844f190
slug: /optimize/avoidoptimizefinal sidebar_label: 'Avoid optimize final' title: 'Avoid Optimize Final' description: 'Using the OPTIMIZE TABLE ... FINAL query will initiate an unscheduled merge of data parts.' doc_type: 'guide' keywords: ['avoid optimize final', 'optimize table final', 'best practices', 'merge data part...
{"source_file": "avoidoptimizefinal.md"}
[ 0.027264632284641266, 0.11884444952011108, -0.00386513932608068, 0.05182744562625885, 0.0049564712680876255, -0.030329864472150803, 0.007973439060151577, 0.07376754283905029, -0.09476440399885178, 0.02824586071074009, 0.06500805914402008, 0.051005955785512924, 0.07513434439897537, -0.07844...
2be39b66-6070-41ef-b6d5-2378214e6e76
slug: /optimize/avoid-mutations sidebar_label: 'Avoid mutations' title: 'Avoid Mutations' description: 'Mutations refers to ALTER queries that manipulate table data' doc_type: 'guide' keywords: ['avoid mutations', 'ALTER queries', 'table data manipulation', 'best practices', 'performance optimization'] import Conte...
{"source_file": "avoidmutations.md"}
[ -0.015101060271263123, 0.06521293520927429, -0.05096358805894852, 0.03923286870121956, 0.0031447713263332844, -0.06662007421255112, 0.0024385079741477966, 0.03740345686674118, -0.0627056136727333, 0.017925655469298363, 0.07485584169626236, 0.022869186475872993, 0.09565875679254532, -0.0776...
76b062dd-40e2-4ac3-ab7b-9c76c9d390be
slug: /optimize/prewhere sidebar_label: 'PREWHERE optimization' sidebar_position: 21 description: 'PREWHERE reduces I/O by avoiding reading unnecessary column data.' title: 'How does the PREWHERE optimization work?' doc_type: 'guide' keywords: ['prewhere', 'query optimization', 'performance', 'filtering', 'best practic...
{"source_file": "prewhere.md"}
[ 0.05251097306609154, 0.07732033729553223, -0.013206173665821552, 0.03651554882526398, 0.061931222677230835, -0.032747771590948105, -0.0017746498342603445, 0.07516175508499146, -0.06697385013103485, 0.023612014949321747, 0.035596150904893875, 0.08262065798044205, 0.08870634436607361, -0.063...
6786fbbe-d648-4940-9ada-5f73ae10f56a
With each step, it only loads granules that contain at least one row that survived—i.e., matched—the previous filter. As a result, the number of granules to load and evaluate for each filter decreases monotonically: Step 1: Filtering by town ClickHouse begins PREWHERE processing by ① reading the selected granules fr...
{"source_file": "prewhere.md"}
[ -0.028644904494285583, -0.015104382298886776, 0.0806141272187233, -0.041450146585702896, 0.01427721232175827, -0.02667839825153351, 0.020327413454651833, -0.048466503620147705, 0.010550575330853462, -0.03016669861972332, -0.04115927964448929, -0.07520722597837448, 0.01653248816728592, -0.0...
61450139-4bbb-41c1-a94c-d387ef945033
How to measure PREWHERE impact {#how-to-measure-prewhere-impact} To validate that PREWHERE is helping your queries, you can compare query performance with and without the optimize_move_to_prewhere setting enabled. We begin by running the query with the optimize_move_to_prewhere setting disabled: sql SELECT ...
{"source_file": "prewhere.md"}
[ 0.08471346646547318, -0.030938688665628433, -0.01892063207924366, 0.05557806044816971, -0.026418063789606094, -0.08202601224184036, 0.04674072936177254, 0.01295201014727354, -0.06183155998587608, 0.04658138006925583, 0.043388381600379944, -0.011546731926500797, 0.010656364262104034, -0.059...
d6abd7b0-b671-4f89-8240-4e8270d113e4
If you want to go even further under the hood, you can observe each individual PREWHERE processing step by instructing ClickHouse to return all test-level log entries during query execution: sql SELECT street FROM uk.uk_price_paid_simple WHERE town = 'LONDON' AND date > '2024-12-31' AND price < 10_000 SETTIN...
{"source_file": "prewhere.md"}
[ 0.06214151903986931, 0.009821825660765171, 0.01474938727915287, 0.07459654659032822, -0.009623954072594643, -0.031941741704940796, 0.02793327532708645, -0.01565314270555973, -0.05882934853434563, 0.06033855676651001, 0.059412818402051926, -0.08041317760944366, 0.02709106169641018, -0.09696...
0c95383c-81bd-4308-b03c-f41a9aa4a55c
slug: /optimize/query-parallelism sidebar_label: 'Query parallelism' sidebar_position: 20 description: 'ClickHouse parallelizes query execution using processing lanes and the max_threads setting.' title: 'How ClickHouse executes a query in parallel' doc_type: 'guide' keywords: ['parallel processing', 'query optimizatio...
{"source_file": "query-parallelism.md"}
[ -0.01452836487442255, 0.00829064566642046, -0.05778435245156288, 0.010905072093009949, -0.04426414147019386, -0.09016875177621841, -0.05016003176569939, 0.031127918511629105, -0.07809390127658844, 0.0005396041669882834, 0.04998940974473953, -0.0034793855156749487, 0.08064394444227219, -0.0...
09e3a7c2-7f97-4302-9c62-4bfd4b75246a
The server that initially receives the query collects all sub-results from the shards and combines them into the final global result. Distributing query load across shards allows horizontal scaling of parallelism, especially for high-throughput environments. :::note ClickHouse Cloud uses parallel replicas instead o...
{"source_file": "query-parallelism.md"}
[ 0.023950990289449692, -0.02348487451672554, 0.04976712167263031, 0.07522610574960709, -0.005468134302645922, -0.11214608699083328, -0.02908690646290779, -0.06515438854694366, 0.06798958778381348, 0.04725491628050804, -0.05789214372634888, -0.037038955837488174, 0.06215474754571915, -0.0652...
49d2f300-adf2-4142-8afd-87846792f66d
sql runnable=false EXPLAIN PIPELINE SELECT max(price) FROM uk.uk_price_paid_simple; txt ┌─explain───────────────────────────────────────────────────────────────────────────┐ 1. │ (Expression) │ 2. │ ExpressionTransform × 59 ...
{"source_file": "query-parallelism.md"}
[ -0.003587067127227783, -0.029607541859149933, -0.01718282885849476, 0.009368648752570152, -0.08447450399398804, -0.09220299869775772, -0.028162967413663864, 0.04552130401134491, -0.03468859940767288, 0.022506238892674446, -0.04311368241906166, -0.003797160694375634, -0.00477156788110733, -...
6e382241-9364-436a-b194-4d73f6d402f2
Why max_threads isn't always respected {#why-max-threads-isnt-always-respected} As mentioned above, the number of n parallel processing lanes is controlled by the max_threads setting, which by default matches the number of CPU cores available to ClickHouse on the server: sql runnable=false SELECT getSetting('max...
{"source_file": "query-parallelism.md"}
[ 0.009213841520249844, -0.0668950155377388, -0.008987975306808949, -0.01569853536784649, -0.06653514504432678, -0.12373349815607071, 0.00988326221704483, -0.034689761698246, -0.01741124875843525, 0.02233550138771534, -0.017001885920763016, -0.018549639731645584, -0.01648298278450966, -0.121...
76d1390d-f6af-4365-8145-a8c12171ad71
For shared-nothing clusters: * merge_tree_min_rows_for_concurrent_read * merge_tree_min_bytes_for_concurrent_read For clusters with shared storage (e.g. ClickHouse Cloud): * merge_tree_min_rows_for_concurrent_read_for_remote_filesystem * merge_tree_min_bytes_for_concurrent_read_for_remote_filesystem Additiona...
{"source_file": "query-parallelism.md"}
[ 0.0476028211414814, -0.07177920639514923, -0.02765539102256298, 0.02369963936507702, -0.0315873920917511, -0.07066130638122559, -0.05726737156510353, 0.015877708792686462, -0.028227197006344795, 0.07589936256408691, 0.021819503977894783, -0.0364251583814621, -0.01343461312353611, -0.030050...
08d3faef-61d9-4220-a259-ca5a0eea7f2c
slug: /optimize/avoid-nullable-columns sidebar_label: 'Avoid nullable Columns' title: 'Avoid nullable Columns' description: 'Why Nullable Columns should be avoided in ClickHouse' doc_type: 'guide' keywords: ['avoid nullable columns', 'nullable columns', 'data types', 'best practices', 'performance optimization'] im...
{"source_file": "avoidnullablecolumns.md"}
[ 0.02823665179312229, 0.06696333736181259, -0.12104876339435577, 0.02774527296423912, 0.03893221914768219, -0.009241471067070961, -0.08330685645341873, 0.015536683611571789, -0.09025179594755173, 0.037299349904060364, 0.09059545397758484, 0.054546572268009186, 0.0481860488653183, -0.0467068...
db642c2a-1ec7-477e-ab54-5e4f14c9acdd
slug: /optimize/partitioning-key sidebar_label: 'Partitioning key' title: 'Choose a Low Cardinality Partitioning Key' description: 'Use a low cardinality partitioning key or avoid using any partitioning key for your table.' doc_type: 'guide' keywords: ['partitioning', 'partition key', 'data organization', 'best practic...
{"source_file": "partitioningkey.md"}
[ 0.09032115340232849, 0.026683861389756203, -0.02260379120707512, -0.009273688308894634, 0.01767788454890251, -0.02394905872642994, -0.005599890369921923, 0.0827920213341713, -0.058022234588861465, 0.032630085945129395, 0.0033239407930523157, -0.008359933272004128, 0.05289706960320473, 0.01...
4fa3fefc-1c7d-4932-a7c3-a679056fc309
slug: /operations/overview sidebar_label: 'Performance and optimizations overview' description: 'Overview page of Performance and Optimizations' title: 'Performance and Optimizations' keywords: ['performance optimization', 'best practices', 'optimization guide', 'ClickHouse performance', 'database optimization'] doc_ty...
{"source_file": "index.md"}
[ 0.008927097544074059, 0.01908419094979763, -0.10278207063674927, 0.026067892089486122, -0.01194357592612505, -0.029999295249581337, 0.011106390506029129, 0.03695613145828247, -0.13554233312606812, 0.02593275159597397, -0.022144729271531105, 0.07949261367321014, 0.057113513350486755, -0.076...
e7e7809a-6314-4059-afc5-c59cf0417c7c
slug: /optimize/bulk-inserts sidebar_label: 'Bulk inserts' title: 'Bulk inserts' description: 'Sending a smaller amount of inserts that each contain more data will reduce the number of writes required.' keywords: ['bulk insert', 'batch insert', 'insert optimization'] doc_type: 'guide' import Content from '@site/doc...
{"source_file": "bulkinserts.md"}
[ -0.0049479068256914616, -0.0055188690312206745, -0.0804128423333168, 0.07308356463909149, -0.02036675624549389, -0.046773575246334076, -0.03850547969341278, 0.049431025981903076, -0.06739485263824463, 0.06876036524772644, 0.0671156719326973, 0.011960864067077637, 0.11146106570959091, -0.04...
6a0623c5-d1cc-490a-a14d-c8f1dcc6e819
slug: /optimize/skipping-indexes sidebar_label: 'Data skipping indexes' sidebar_position: 2 description: 'Skip indexes enable ClickHouse to skip reading significant chunks of data that are guaranteed to have no matching values.' title: 'Understanding ClickHouse Data Skipping Indexes' doc_type: 'guide' keywords: ['skipp...
{"source_file": "skipping-indexes.md"}
[ 0.016621064394712448, 0.11320773512125015, 0.03685493767261505, 0.03490219637751579, 0.05131816118955612, -0.05776825547218323, 0.03341901674866676, -0.013481926172971725, -0.019106362015008926, -0.01800605095922947, 0.07394257187843323, 0.05775866284966469, 0.09943407773971558, -0.0688535...
3bcad78d-35bc-48c4-bafc-c6392e06adbd
Index name. The index name is used to create the index file in each partition. Also, it is required as a parameter when dropping or materializing the index. Index expression. The index expression is used to calculate the set of values stored in the index. It can be a combination of columns, simple operators, and/or a...
{"source_file": "skipping-indexes.md"}
[ -0.033035147935152054, 0.02458769455552101, 0.0022948216646909714, 0.03670960292220116, 0.046143222600221634, -0.037337906658649445, 0.08495093882083893, 0.027417343109846115, 0.08392694592475891, -0.027352066710591316, -0.013423134572803974, 0.04935714229941368, 0.01692662015557289, -0.08...
058716a6-2916-401d-9430-6d5b646e39ab
Instead of processing 100 million rows of 800 megabytes, ClickHouse has only read and analyzed 32768 rows of 360 kilobytes -- four granules of 8192 rows each. In a more visual form, this is how the 4096 rows with a my_value of 125 were read and selected, and how the following rows were skipped without reading from ...
{"source_file": "skipping-indexes.md"}
[ 0.05709846690297127, -0.029370274394750595, 0.01146199181675911, 0.06804028898477554, 0.008486540988087654, -0.10399085283279419, 0.03655761480331421, -0.012415915727615356, -0.006583582144230604, 0.0032215218525379896, 0.0172534491866827, -0.01169682014733553, 0.020731719210743904, -0.098...
fb1e5ac3-6480-47de-9e3b-cd5bd3946f0c
Because Bloom filters can more efficiently handle testing for a large number of discrete values, they can be appropriate for conditional expressions that produce more values to test. In particular, a Bloom filter index can be applied to arrays, where every value of the array is tested, and to maps, by converting either...
{"source_file": "skipping-indexes.md"}
[ 0.010774503462016582, 0.0700305923819542, 0.08283759653568268, 0.02952462062239647, 0.02004212699830532, -0.003979322500526905, 0.021704407408833504, -0.045364800840616226, 0.11133552342653275, 0.00943745020776987, -0.05253211781382561, 0.019196966663002968, -0.014660445041954517, -0.04429...
59a1f175-dc9b-412c-bc53-032d7fdfe279
Each type of skip index works on a subset of available ClickHouse functions appropriate to the index implementation listed here . In general, set indexes and Bloom filter based indexes (another type of set index) are both unordered and therefore do not work with ranges. In contrast, minmax indexes work particularly we...
{"source_file": "skipping-indexes.md"}
[ -0.00298171560280025, 0.029057122766971588, 0.054152265191078186, 0.021425805985927582, 0.019250547513365746, 0.005893357563763857, 0.011284449137747288, -0.07183143496513367, 0.013051937334239483, -0.07270302623510361, 0.0426928773522377, -0.003502113511785865, -0.005399580579251051, -0.0...
4116ba67-5135-4b5c-bc83-75e50309c999
Accordingly, the natural impulse to try to speed up ClickHouse queries by simply adding an index to key columns is often incorrect. This advanced functionality should only be used after investigating other alternatives, such as modifying the primary key (see How to Pick a Primary Key ), using projections, or using ma...
{"source_file": "skipping-indexes.md"}
[ 0.002509539248421788, -0.02721363492310047, 0.010161123238503933, 0.019533028826117516, -0.0009753414196893573, 0.008465501479804516, 0.01847340539097786, -0.06318169087171555, 0.04298314452171326, -0.04786697402596474, 0.010179380886256695, 0.0104509387165308, -0.008353691548109055, -0.06...
57a80f85-6187-46ba-9c52-6e4ccdd60aed
slug: /optimize/skipping-indexes/examples sidebar_label: 'Data Skipping Indexes - Examples' sidebar_position: 2 description: 'Consolidated Skip Index Examples' title: 'Data Skipping Index Examples' doc_type: 'guide' keywords: ['skipping indexes', 'data skipping', 'performance', 'indexing', 'best practices'] Data sk...
{"source_file": "skipping-indexes-examples.md"}
[ 0.06194494292140007, -0.011891200207173824, 0.09508699178695679, 0.032226815819740295, -0.018362168222665787, -0.04888846352696419, 0.021036524325609207, -0.00849500484764576, -0.06654227524995804, -0.024957910180091858, 0.048641376197338104, -0.005398642271757126, 0.04431501403450966, -0....
470b6219-5b4f-4ee1-bf02-6b0adc34558c
SELECT * FROM events WHERE value IN (7, 42, 99); EXPLAIN indexes = 1 SELECT * FROM events WHERE value IN (7, 42, 99); ``` N-gram Bloom filter (ngrambf_v1) for substring search {#n-gram-bloom-filter-ngrambf-v1-for-substring-search} The ngrambf_v1 index splits strings into n-grams. It works well for LIKE '%...%'...
{"source_file": "skipping-indexes-examples.md"}
[ 0.005593861918896437, 0.014381765387952328, 0.009681930765509605, 0.059326689690351486, -0.01715361885726452, 0.07211934030056, 0.08799733966588974, 0.0335458368062973, 0.017215188592672348, 0.001450696843676269, -0.05172949284315109, 0.00845731794834137, -0.01033847127109766, -0.039753206...
777f6a07-3f3c-4ee7-ba2e-9323ff6f12e2
```sql CREATE TABLE t ( u64 UInt64, s String, m Map(String, String), INDEX idx_bf u64 TYPE bloom_filter(0.01) GRANULARITY 3, INDEX idx_minmax u64 TYPE minmax GRANULARITY 1, INDEX idx_set u64 * length(s) TYPE set(1000) GRANULARITY 4, INDEX idx_ngram s TYPE ngrambf_v1(3, 10000, 3, 7) GRANULARITY 1, INDEX ...
{"source_file": "skipping-indexes-examples.md"}
[ 0.021607523784041405, 0.029821548610925674, 0.028927145525813103, -0.007774892263114452, -0.005909481551498175, -0.04239964485168457, 0.028281062841415405, 0.023508155718445778, -0.0856500193476677, 0.02014225535094738, -0.007601824589073658, 0.005930731073021889, 0.02152036316692829, -0.0...
221dd966-1df5-41fe-a3ac-d4f0f6deffa6
slug: /optimize/asynchronous-inserts sidebar_label: 'Asynchronous Inserts' title: 'Asynchronous Inserts (async_insert)' description: 'Use asynchronous inserts as an alternative to batching data.' doc_type: 'guide' keywords: ['asynchronous inserts', 'async_insert', 'best practices', 'batching data', 'performance optimiz...
{"source_file": "asyncinserts.md"}
[ -0.03953497111797333, 0.051444217562675476, -0.09483049809932709, 0.1295595020055771, -0.04950787499547005, -0.01915283128619194, -0.04419364780187607, 0.05124066397547722, -0.06284795701503754, -0.020456861704587936, 0.06376907229423523, 0.059822928160429, 0.079768106341362, -0.0782319679...
2cf04327-f157-4465-bc17-21c63db60ede
slug: '/examples/aggregate-function-combinators/uniqArrayIf' title: 'uniqArrayIf' description: 'Example of using the uniqArrayIf combinator' keywords: ['uniq', 'array', 'if', 'combinator', 'examples', 'uniqArrayIf'] sidebar_label: 'uniqArrayIf' doc_type: 'reference' uniqArrayIf {#uniqarrayif} Description {#descri...
{"source_file": "uniqArrayIf.md"}
[ -0.0010597174987196922, 0.004011173732578754, -0.014808060601353645, 0.046186160296201706, -0.027381308376789093, 0.08606909960508347, 0.10078056156635284, 0.00392708508297801, 0.04705769196152687, -0.058379653841257095, 0.024850420653820038, -0.0025529905688017607, 0.1404641717672348, 0.0...
9a827383-11e1-42bb-9517-827445fef989
slug: '/examples/aggregate-function-combinators/sumSimpleState' title: 'sumSimpleState' description: 'Example of using the sumSimpleState combinator' keywords: ['sum', 'state', 'simple', 'combinator', 'examples', 'sumSimpleState'] sidebar_label: 'sumSimpleState' doc_type: 'reference' sumSimpleState {#sumsimplestate...
{"source_file": "sumSimpleState.md"}
[ -0.09811026602983475, -0.001073782448656857, -0.01046434510499239, 0.05407912656664848, -0.017519893124699593, 0.0811958760023117, 0.044268060475587845, 0.05085968226194382, -0.007909854874014854, -0.005559615325182676, -0.04818800464272499, -0.05801807716488838, 0.052257828414440155, 0.00...
fdf17cf9-9672-4cfb-abd3-c7a3fdaf0390
slug: '/examples/aggregate-function-combinators/avgMerge' title: 'avgMerge' description: 'Example of using the avgMerge combinator' keywords: ['avg', 'merge', 'combinator', 'examples', 'avgMerge'] sidebar_label: 'avgMerge' doc_type: 'reference' avgMerge {#avgMerge} Description {#description} The Merge combina...
{"source_file": "avgMerge.md"}
[ -0.04121572524309158, 0.011534501798450947, 0.04372968524694443, 0.05847730487585068, -0.018030548468232155, 0.0376821905374527, 0.06280435621738434, 0.02510455995798111, -0.011274863965809345, -0.018767980858683586, -0.000605533248744905, -0.021208327263593674, 0.010464679449796677, -0.02...
00b08df8-8741-4b78-90cd-ec00357e818b
slug: '/examples/aggregate-function-combinators/uniqArray' title: 'uniqArray' description: 'Example of using the uniqArray combinator' keywords: ['uniq', 'array', 'combinator', 'examples', 'uniqArray'] sidebar_label: 'uniqArray' doc_type: 'reference' uniqArray {#uniqarray} Description {#description} The Array ...
{"source_file": "uniqArray.md"}
[ 0.005837088450789452, 0.00039517597178928554, -0.03232084959745407, 0.02217342145740986, -0.02748902514576912, -0.01091686636209488, 0.07838691025972366, 0.00021855415252503008, 0.024687932804226875, -0.07307783514261246, 0.0182868130505085, 0.02261737920343876, 0.12054786086082458, -0.023...
048929d9-5e6e-4f08-afdf-5c65f22b7452
slug: '/examples/aggregate-function-combinators/sumIf' title: 'sumIf' description: 'Example of using the sumIf combinator' keywords: ['sum', 'if', 'combinator', 'examples', 'sumIf'] sidebar_label: 'sumIf' doc_type: 'reference' sumIf {#sumif} Description {#description} The If combinator can be applied to the ...
{"source_file": "sumIf.md"}
[ -0.03833799436688423, 0.03717745468020439, -0.007202391512691975, 0.016695570200681686, -0.08572235703468323, 0.041634395718574524, 0.10724872350692749, 0.09529362618923187, 0.04652319476008415, 0.03965085372328758, 0.03522009029984474, -0.08922816812992096, 0.06267845630645752, -0.0224341...
c606f636-df08-479d-a5a5-81038868635a
markdown ┌──────month─┬─volume_on_up_days─┬─volume_on_down_days─┬─volume_on_neutral_days─┬─total_volume──┐ 1. │ 2002-01-01 │ 26.07 billion │ 30.74 billion │ 781.80 million │ 57.59 billion │ 2. │ 2002-02-01 │ 20.84 billion │ 29.60 billion │ 642.36 million │ 51.09 billion │ 3. │...
{"source_file": "sumIf.md"}
[ 0.017664149403572083, -0.010191491805016994, -0.021433023735880852, 0.03038734570145607, 0.03501658886671066, -0.09739507734775543, 0.019473925232887268, 0.029399007558822632, 0.0004519362119026482, 0.08858555555343628, 0.06755142658948898, -0.031102189794182777, 0.05058487132191658, -0.01...
f1cf4f2e-4281-4017-a599-7525363f6825
markdown title="Response" ┌──────month─┬─apple_volume───┬─microsoft_volume─┬─google_volume──┬─total_volume─┬─major_tech_percentage─┐ 1. │ 2006-01-01 │ 782.21 million │ 1.39 billion │ 299.69 million │ 84343937700 │ 2.93 │ 2. │ 2006-02-01 │ 670.38 million │ 1.05 billion │ 297.65 million │ ...
{"source_file": "sumIf.md"}
[ -0.0007716430118307471, 0.03141718730330467, 0.00043811716022901237, 0.043482400476932526, -0.00904170610010624, -0.07876048982143402, 0.020769914612174034, 0.05937454476952553, 0.02742280252277851, 0.05945782735943794, 0.019461331889033318, -0.040292706340551376, 0.07566133886575699, -0.0...
0d4780dd-49c6-4d5c-9825-8d8f613ff492
slug: '/examples/aggregate-function-combinators/quantilesTimingArrayIf' title: 'quantilesTimingArrayIf' description: 'Example of using the quantilesTimingArrayIf combinator' keywords: ['quantilesTiming', 'array', 'if', 'combinator', 'examples', 'quantilesTimingArrayIf'] sidebar_label: 'quantilesTimingArrayIf' doc_type:...
{"source_file": "quantilesTimingArrayIf.md"}
[ -0.042661286890506744, 0.04176223278045654, -0.0336357057094574, 0.029910597950220108, -0.08338414132595062, -0.018817074596881866, 0.047837793827056885, 0.022791795432567596, 0.01113581471145153, -0.028003837913274765, 0.0017348098335787654, -0.06978225708007812, 0.0056218840181827545, -0...
f49ca267-1b9d-4891-a551-ab34aa29d0da
slug: '/examples/aggregate-function-combinators/avgResample' title: 'avgResample' description: 'Example of using the Resample combinator with avg' keywords: ['avg', 'Resample', 'combinator', 'examples', 'avgResample'] sidebar_label: 'avgResample' doc_type: 'reference' countResample {#countResample} Description {#...
{"source_file": "avgResample.md"}
[ -0.038262076675891876, 0.001977404346689582, 0.020670272409915924, 0.038601282984018326, -0.10059691220521927, 0.01569153554737568, 0.02923034504055977, 0.06490831077098846, -0.023359134793281555, -0.013853429816663265, -0.014706493355333805, -0.024910634383559227, 0.04811261594295502, -0....
7197fbeb-da9f-437c-a6f1-cd34194fe999
slug: '/examples/aggregate-function-combinators/countIf' title: 'countIf' description: 'Example of using the countIf combinator' keywords: ['count', 'if', 'combinator', 'examples', 'countIf'] sidebar_label: 'countIf' doc_type: 'reference' countIf {#countif} Description {#description} The If combinator can be ...
{"source_file": "countIf.md"}
[ 0.010116915218532085, 0.008647819980978966, 0.015050348825752735, 0.05178871750831604, -0.08039022237062454, 0.06317058205604553, 0.08556748926639557, 0.09655016660690308, 0.07358287274837494, 0.01089206151664257, 0.06957290321588516, -0.08981063961982727, 0.123927041888237, -0.00257162912...
7342e93e-7f17-4e31-83d3-9df499d96e64
slug: '/examples/aggregate-function-combinators/avgMap' title: 'avgMap' description: 'Example of using the avgMap combinator' keywords: ['avg', 'map', 'combinator', 'examples', 'avgMap'] sidebar_label: 'avgMap' doc_type: 'reference' avgMap {#avgmap} Description {#description} The Map combinator can be applied...
{"source_file": "avgMap.md"}
[ 0.010913504287600517, 0.0035193904768675566, -0.0074373590759932995, 0.04380396753549576, -0.10084350407123566, -0.005288496147841215, 0.06692703068256378, 0.07411015033721924, -0.014008406549692154, 0.06665793806314468, 0.013227598741650581, -0.06728856265544891, 0.07505639642477036, -0.0...
0b42eca6-f1b9-48f4-a5fc-88f032e0d975
slug: '/examples/aggregate-function-combinators/groupArrayDistinct' title: 'groupArrayDistinct' description: 'Example of using the groupArrayDistinct combinator' keywords: ['groupArray', 'Distinct', 'combinator', 'examples', 'groupArrayDistinct'] sidebar_label: 'groupArrayDistinct' doc_type: 'reference' groupArrayD...
{"source_file": "groupArrayDistinct.md"}
[ 0.022396190091967583, -0.019927682355046272, -0.09455271810293198, 0.041815489530563354, -0.07371890544891357, -0.0268209557980299, 0.0847579762339592, -0.019693676382303238, 0.018338164314627647, -0.05288953706622124, -0.013186750002205372, 0.0026404461823403835, 0.09927337616682053, -0.0...
82ccfcdb-1a39-4cb0-b9fa-f4344d080842
slug: '/examples/aggregate-function-combinators/sumArray' title: 'sumArray' description: 'Example of using the sumArray combinator' keywords: ['sum', 'array', 'combinator', 'examples', 'sumArray'] sidebar_label: 'sumArray' doc_type: 'reference' sumArray {#sumarray} Description {#description} The Array combina...
{"source_file": "sumArray.md"}
[ -0.002363083651289344, 0.03491871431469917, -0.017952054738998413, 0.057469893246889114, -0.09362787008285522, -0.003241335740312934, 0.06790363788604736, 0.043078720569610596, -0.004028339870274067, -0.02859816886484623, -0.022341609001159668, -0.026691444218158722, 0.043100763112306595, ...
e51d5264-79ec-45dc-85c4-b2ccdec62447
slug: '/examples/aggregate-function-combinators/anyIf' title: 'anyIf' description: 'Example of using the anyIf combinator' keywords: ['any', 'if', 'combinator', 'examples', 'anyIf'] sidebar_label: 'anyIf' doc_type: 'reference' anyIf {#avgif} Description {#description} The If combinator can be applied to the ...
{"source_file": "anyIf.md"}
[ -0.03332899883389473, 0.041535235941410065, 0.003260944038629532, 0.004756542854011059, -0.047949645668268204, 0.05315535515546799, 0.10995006561279297, 0.08795724809169769, 0.04026157781481743, 0.040870025753974915, 0.08868981897830963, -0.04797469452023506, 0.05777306109666824, -0.090354...
14019d1b-d885-45d1-9187-05c55e605994
slug: '/examples/aggregate-function-combinators/maxMap' title: 'maxMap' description: 'Example of using the maxMap combinator' keywords: ['max', 'map', 'combinator', 'examples', 'maxMap'] sidebar_label: 'maxMap' doc_type: 'reference' maxMap {#maxmap} Description {#description} The Map combinator can be applied...
{"source_file": "maxMap.md"}
[ 0.02465267851948738, 0.00043322343844920397, 0.04901241138577461, -0.006086159963160753, -0.1177004724740982, 0.017256293445825577, 0.026120500639081, 0.08784354478120804, -0.03507443889975548, 0.061198920011520386, 0.017538245767354965, -0.02884361892938614, 0.08260896056890488, -0.016100...
2f63b445-007a-4acd-b53d-d11e92a3d592
slug: '/examples/aggregate-function-combinators/quantilesTimingIf' title: 'quantilesTimingIf' description: 'Example of using the quantilesTimingIf combinator' keywords: ['quantilesTiming', 'if', 'combinator', 'examples', 'quantilesTimingIf'] sidebar_label: 'quantilesTimingIf' doc_type: 'reference' quantilesTimingIf...
{"source_file": "quantilesTimingIf.md"}
[ -0.06531300395727158, 0.05027293041348457, 0.002704873215407133, 0.04130786284804344, -0.08377345651388168, -0.024675047025084496, 0.029609955847263336, 0.05215649679303169, 0.033789072185754776, -0.00693748751655221, 0.034893665462732315, -0.11681226640939713, 0.01750745251774788, -0.0228...
12cc1d23-6b61-4858-846f-626bad6ebfff
slug: '/examples/aggregate-function-combinators/minSimpleState' title: 'minSimpleState' description: 'Example of using the minSimpleState combinator' keywords: ['min', 'state', 'simple', 'combinator', 'examples', 'minSimpleState'] sidebar_label: 'minSimpleState' doc_type: 'reference' minSimpleState {#minsimplestate...
{"source_file": "minSimpleState.md"}
[ -0.01241270825266838, 0.03511328622698784, 0.041710738092660904, 0.11546140164136887, -0.06821369379758835, 0.03552412614226341, 0.02876480482518673, 0.13258571922779083, -0.02142353169620037, 0.01230809185653925, 0.020416459068655968, -0.1468772292137146, 0.09353715181350708, -0.026697061...
8eb5c21c-0e11-462b-b672-046c860f30ae
Insert some more data: sql INSERT INTO raw_temperature_readings (location_id, location_name, temperature) VALUES (1, 'North', 3), (2, 'South', 18), (3, 'West', 10), (1, 'North', 8), (4, 'East', 2); View the updated extremes after new data: sql SELECT location_id, location_name, min...
{"source_file": "minSimpleState.md"}
[ 0.03342537209391594, -0.0398252010345459, 0.1046367958188057, 0.07482405006885529, -0.023512164130806923, -0.029481057077646255, -0.016894232481718063, -0.04541531205177307, -0.019901514053344727, 0.023874707520008087, 0.07181524485349655, -0.05741347372531891, 0.03491843864321709, -0.0588...
a80c1017-1fe4-4e1e-9399-04e9f1877c3c
slug: '/examples/aggregate-function-combinators/sumForEach' title: 'sumForEach' description: 'Example of using the sumForEach aggregate function' keywords: ['sum', 'ForEach', 'combinator', 'examples', 'sumForEach'] sidebar_label: 'sumForEach' doc_type: 'reference' sumForEach {#sumforeach} Description {#descriptio...
{"source_file": "sumForEach.md"}
[ 0.005476975813508034, -0.035665564239025116, 0.00901293195784092, 0.00852088164538145, -0.0426008403301239, 0.0005184769397601485, 0.10728541016578674, 0.0030256998725235462, -0.008653471246361732, 0.02484889328479767, -0.023583097383379936, -0.07376217097043991, 0.09755569696426392, -0.02...