id stringlengths 36 36 | document stringlengths 3 3k | metadata stringlengths 23 69 | embeddings listlengths 384 384 |
|---|---|---|---|
2b59ae71-7f07-4b4b-b96e-dd898f0e70fd | Count the number of rows {#count-row-numbers}
Open a new tab in the SQL Console of ClickHouse Cloud (or a new
clickhouse-client
window) and watch the count increase.
It will take a while to insert 4.56B rows, depending on your server resources. (Without any tweaking of settings, it takes about 4.5 hours.)
sql
SEL... | {"source_file": "youtube-dislikes.md"} | [
0.06096687167882919,
-0.11603061854839325,
-0.04081161692738533,
0.03326932340860367,
-0.034452907741069794,
0.012982094660401344,
0.0738319531083107,
-0.03695637360215187,
0.08703657984733582,
0.04827504977583885,
0.017288396134972572,
-0.013815336860716343,
0.09796030819416046,
-0.052499... |
9282cbfb-e989-418d-8f09-a98ff13039c3 | response
1174 rows in set. Elapsed: 1099.368 sec. Processed 4.56 billion rows, 1.98 TB (4.15 million rows/s., 1.80 GB/s.)
The results look like:
response
ββview_countββ¬βlike_countββ¬βdislike_countββ¬βurlβββββββββββββββββββββββββββ¬βtitleββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ... | {"source_file": "youtube-dislikes.md"} | [
-0.054224979132413864,
-0.08247828483581543,
0.02970557101070881,
0.02919684909284115,
0.01797279343008995,
-0.03504704684019089,
0.09610934555530548,
0.005089261569082737,
0.020776789635419846,
-0.010593373328447342,
0.022014154121279716,
-0.0030232074204832315,
0.014203036203980446,
-0.0... |
e8a351cd-724b-4ade-a12c-d8b188029345 | ```response
ββviewsββββββββββββββ¬βis_comments_enabledββ¬ββββprob_like_dislikeββ
β < 10.00 β false β 0.08224180712685371 β
β < 100.00 β false β 0.06346337759167248 β
β < 1.00 thousand β false β 0.03201883652987105 β
β < 10.00 thousand β false ... | {"source_file": "youtube-dislikes.md"} | [
-0.03726746141910553,
-0.04116787016391754,
-0.02481013536453247,
0.06378574669361115,
-0.008750081062316895,
-0.09837654232978821,
0.05185367166996002,
-0.009550266899168491,
0.04249829053878784,
0.07248897105455399,
0.04716469720005989,
-0.029715947806835175,
0.07634606957435608,
-0.0095... |
ae414bb6-1223-4bed-97c1-3d2ac1388010 | response
βββββββmonthββ¬βuploadersββ¬βnum_videosββ¬βββview_countββ
β 2005-04-01 β 5 β 6 β 213597737 β
β 2005-05-01 β 6 β 9 β 2944005 β
β 2005-06-01 β 165 β 351 β 18624981 β
β 2005-07-01 β 395 β 1168 β 94164872 β
β 2005-08-01 β 1171 β 312... | {"source_file": "youtube-dislikes.md"} | [
-0.0384845994412899,
0.024668626487255096,
-0.021796340122818947,
0.03239550068974495,
-0.010011397302150726,
-0.08385064452886581,
0.005729726981371641,
0.006535158026963472,
-0.005450059659779072,
0.0895993635058403,
0.03708774968981743,
-0.007706001400947571,
0.04212633892893791,
-0.037... |
c8b31892-f1ec-4ba7-988d-3d66a7ea62a2 | Top uploaders over time {#top-uploaders-over-time}
sql
WITH uploaders AS
(
SELECT uploader
FROM youtube
GROUP BY uploader
ORDER BY sum(view_count) DESC
LIMIT 10
)
SELECT
month,
uploader,
sum(view_count) AS total_views,
avg(dislike_count / like_count) AS ... | {"source_file": "youtube-dislikes.md"} | [
-0.0024216410238295794,
-0.12692312896251678,
-0.04834849014878273,
0.056933898478746414,
0.01185578852891922,
0.05185047909617424,
0.05449628084897995,
-0.034967392683029175,
0.0023058978840708733,
0.04095906764268875,
0.07291907072067261,
-0.04837768152356148,
0.05724029988050461,
-0.014... |
c44c2e66-7b07-4ed1-ae98-c1961b26e5ff | response
ββview_rangeβββββββββ¬βis_comments_enabledββ¬βlike_ratioββ
β < 10.00 β false β 0.66 β
β < 10.00 β true β 0.66 β
β < 100.00 β false β 3 β
β < 100.00 β true β 3.95 β
β < 1.00 thousand β fals... | {"source_file": "youtube-dislikes.md"} | [
-0.02950475364923477,
0.013996010646224022,
-0.03606121987104416,
0.07991353422403336,
0.0026207019109278917,
-0.09827417135238647,
0.04143402725458145,
-0.007273945491760969,
0.02128695137798786,
0.09903004765510559,
0.038867972791194916,
-0.0849011242389679,
0.08366856724023819,
-0.02451... |
2a446bee-7e5c-4473-8f54-32e12568ef5a | description: 'Dataset consisting of two tables containing anonymized web analytics
data with hits and visits'
sidebar_label: 'Anonymized web analytics'
slug: /getting-started/example-datasets/metrica
keywords: ['web analytics data', 'anonymized data', 'website traffic data', 'example dataset', 'getting started']
titl... | {"source_file": "anon_web_analytics_metrica.md"} | [
-0.05901256203651428,
0.0019315379904583097,
-0.09357232600450516,
0.08415812999010086,
0.02775081992149353,
-0.09569745510816574,
0.07380328327417374,
0.0011178248096257448,
-0.024475524201989174,
0.05899645388126373,
0.051084183156490326,
-0.0034443307667970657,
0.07118413597345352,
-0.0... |
dd434f33-1dae-4c92-9ae7-3e378fb5a7fa | bash | {"source_file": "anon_web_analytics_metrica.md"} | [
0.04660592973232269,
0.04472070559859276,
-0.0543510839343071,
-0.014888063073158264,
-0.015997320413589478,
0.015274093486368656,
0.14817704260349274,
0.05366526171565056,
0.0529615581035614,
0.011088280938565731,
0.012236982583999634,
0.00711818877607584,
0.05829260125756264,
-0.01846610... |
b2c3ecc0-4649-4f74-93e5-8dd775cbde5e | clickhouse-client --query "CREATE TABLE datasets.hits_v1 ( 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, OS UInt8, UserAgent UInt8, URL St... | {"source_file": "anon_web_analytics_metrica.md"} | [
0.046896472573280334,
-0.007800644729286432,
-0.07952014356851578,
0.004175643436610699,
-0.069439597427845,
0.0000018133076764570433,
0.04484327509999275,
-0.03038785047829151,
-0.03158089891076088,
0.016364865005016327,
0.015261606313288212,
-0.08847454190254211,
0.026312269270420074,
-0... |
fdb3758a-6cf0-408a-82a4-e7fb124873d7 | String, Key3 String, Key4 String, Key5 String, ValueDouble Float64), IslandID FixedString(16), RequestNum UInt32, RequestTry UInt8) ENGINE = MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate, intHash32(UserID)) SAMPLE BY intHash32(UserID) SETTINGS index_granularity = 8192" | {"source_file": "anon_web_analytics_metrica.md"} | [
0.08101499825716019,
0.028779970481991768,
0.011179903522133827,
-0.048611730337142944,
-0.10557550936937332,
-0.0183505080640316,
0.049439139664173126,
0.08719577640295029,
-0.019993968307971954,
0.0022745647002011538,
0.031189464032649994,
-0.03615783900022507,
0.010382520966231823,
-0.0... |
40ba947b-d6dc-4bea-8249-35dc2267549c | Or for hits_100m_obfuscated
bash
clickhouse-client --query="CREATE TABLE default.hits_100m_obfuscated (WatchID UInt64, JavaEnable UInt8, Title String, GoodEvent Int16, EventTime DateTime, EventDate Date, CounterID UInt32, ClientIP UInt32, RegionID UInt32, UserID UInt64, CounterClass Int8, OS UInt8, UserAgent UInt8, U... | {"source_file": "anon_web_analytics_metrica.md"} | [
0.010220317170023918,
0.03322073072195053,
-0.09534479677677155,
0.008979536592960358,
-0.017960581928491592,
-0.015085941180586815,
0.0663776844739914,
0.0415186770260334,
-0.03028946742415428,
0.016251567751169205,
0.021633116528391838,
-0.03387398645281792,
0.07059761881828308,
-0.04152... |
317ae6b5-aecd-4e1e-890b-45d14f60b66c | Validate the checksum
md5sum visits_v1.tsv
Checksum should be equal to: 6dafe1a0f24e59e3fc2d0fed85601de6
```
Create the visits table {#create-the-visits-table} | {"source_file": "anon_web_analytics_metrica.md"} | [
0.01721673272550106,
-0.02658265084028244,
-0.04489205405116081,
-0.017185397446155548,
0.010886000469326973,
-0.0489896796643734,
0.05901721119880676,
-0.044942159205675125,
-0.040373384952545166,
0.10214998573064804,
-0.020754633471369743,
-0.044947072863578796,
0.047155119478702545,
0.0... |
5ab1ed35-d449-4698-a5d9-e21c6b5c16ec | bash | {"source_file": "anon_web_analytics_metrica.md"} | [
0.04660592973232269,
0.04472070559859276,
-0.0543510839343071,
-0.014888063073158264,
-0.015997320413589478,
0.015274093486368656,
0.14817704260349274,
0.05366526171565056,
0.0529615581035614,
0.011088280938565731,
0.012236982583999634,
0.00711818877607584,
0.05829260125756264,
-0.01846610... |
a7a3668a-2db5-4b6f-af40-9726c8fd1e93 | clickhouse-client --query "CREATE TABLE datasets.visits_v1 ( CounterID UInt32, StartDate Date, Sign Int8, IsNew UInt8, VisitID UInt64, UserID UInt64, StartTime DateTime, Duration UInt32, UTCStartTime DateTime, PageViews Int32, Hits Int32, IsBounce UInt8, Referer String, StartURL String, RefererDomain Stri... | {"source_file": "anon_web_analytics_metrica.md"} | [
0.05436433106660843,
-0.019639335572719574,
-0.07723738253116608,
0.028764359652996063,
-0.07528124004602432,
0.0290616936981678,
0.053577907383441925,
-0.04017167165875435,
-0.016288289800286293,
0.0010476905154064298,
0.03025757521390915,
-0.076897032558918,
0.059775419533252716,
-0.0706... |
b804dfc8-2271-45a0-a5b7-059e6cea845f | String, UTMTerm String, FromTag String, HasGCLID UInt8, FirstVisit DateTime, PredLastVisit Date, LastVisit Date, TotalVisits UInt32, TraficSource Nested(ID Int8, SearchEngineID UInt16, AdvEngineID UInt8, PlaceID UInt16, SocialSourceNetworkID UInt8, Domain String, SearchPhrase String, SocialSourcePage String... | {"source_file": "anon_web_analytics_metrica.md"} | [
-0.000762571522500366,
-0.0006358679966069758,
-0.05967727676033974,
-0.07781515270471573,
-0.049351904541254044,
0.009733932092785835,
0.02531087026000023,
0.0013093086890876293,
-0.027418894693255424,
0.021544955670833588,
0.0626751109957695,
-0.006481626071035862,
0.08951079845428467,
-... |
0b45fb08-c258-4486-8f5f-bf1d54edbf66 | Import the visits data {#import-the-visits-data}
bash
cat visits_v1.tsv | clickhouse-client --query "INSERT INTO datasets.visits_v1 FORMAT TSV" --max_insert_block_size=100000
Verify the count
bash
clickhouse-client --query "SELECT COUNT(*) FROM datasets.visits_v1"
response
1680609
An example JOIN {#an-example-... | {"source_file": "anon_web_analytics_metrica.md"} | [
0.055428896099328995,
-0.027284884825348854,
-0.003505272790789604,
0.10330019891262054,
-0.08898206055164337,
-0.026139114052057266,
0.022636398673057556,
0.010034739039838314,
-0.03962942585349083,
0.014076050370931625,
-0.0016267092432826757,
-0.024969838559627533,
0.0539153628051281,
-... |
988b8151-f980-4b98-b657-805409a26799 | description: 'Learn how to load OpenCelliD data into ClickHouse, connect Apache Superset
to ClickHouse and build a dashboard based on data'
sidebar_label: 'Cell towers'
slug: /getting-started/example-datasets/cell-towers
title: 'Geo Data using the Cell Tower Dataset'
keywords: ['cell tower data', 'geo data', 'OpenCel... | {"source_file": "cell-towers.md"} | [
0.029849251732230186,
-0.0038197762332856655,
-0.06117204204201698,
-0.02004207670688629,
-0.09315671771764755,
-0.010807499289512634,
0.00401597935706377,
0.0712035521864891,
-0.02438409812748432,
-0.0079755038022995,
0.07657238841056824,
-0.027002708986401558,
0.06900957971811295,
-0.070... |
83e08f84-7ef3-4f82-bba3-e2cfa8b01a4c | As of 2021, it contains more than 40 million records about cell towers (GSM, LTE, UMTS, etc.) around the world with their geographical coordinates and metadata (country code, network, etc.).
OpenCelliD Project is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License, and we redistribute a... | {"source_file": "cell-towers.md"} | [
-0.009251940064132214,
-0.04259319230914116,
-0.05156182497739792,
-0.038838163018226624,
0.0012956972932443023,
-0.007276127580553293,
-0.058991942554712296,
-0.0452008917927742,
0.030062634497880936,
0.04482338950037956,
0.06050474941730499,
-0.03433206304907799,
0.07554519921541214,
-0.... |
a642148a-072e-4d74-8556-8e93f627bd98 | Import the dataset from a public S3 bucket (686 MB):
sql
INSERT INTO cell_towers SELECT * FROM s3('https://datasets-documentation.s3.amazonaws.com/cell_towers/cell_towers.csv.xz', 'CSVWithNames')
Run some example queries {#examples}
A number of cell towers by type:
sql
SELECT radio, count() AS c FROM ... | {"source_file": "cell-towers.md"} | [
0.011389786377549171,
-0.057906560599803925,
-0.07274176925420761,
0.017870847135782242,
-0.012060794979333878,
-0.055688850581645966,
-0.00521763926371932,
-0.03291609138250351,
0.018450234085321426,
0.07043188065290451,
0.05479399114847183,
-0.06667432934045792,
0.12122742086648941,
-0.1... |
c13a93cf-d4ac-47d8-8f0b-521a23f961a0 | sql
INSERT INTO moscow VALUES ([(37.84172564285271, 55.78000432402266),
(37.8381207618713, 55.775874525970494), (37.83979446823122, 55.775626746008065), (37.84243326983639, 55.77446586811748), (37.84262672750849, 55.771974101091104), (37.84153238623039, 55.77114545193181), (37.841124690460184, 55.76722010265554),
(37.8... | {"source_file": "cell-towers.md"} | [
0.05789320543408394,
-0.021605301648378372,
-0.030114345252513885,
0.03195003792643547,
-0.0825711190700531,
-0.007224237080663443,
0.06822624057531357,
0.002275067148730159,
-0.04897594824433327,
-0.00930190458893776,
-0.08026532828807831,
-0.00018978185835294425,
0.02081187628209591,
0.0... |
12119a49-7130-4fde-bf52-ab9e1fcfb916 | (37.77801986242668, 55.618770300976294), (37.778212973541216, 55.617257701952106), (37.77784818518065, 55.61574504433011), (37.77016867724609, 55.61148576294007), (37.760191219573976, 55.60599579539028), (37.75338926983641, 55.60227892751446),
(37.746329965606634, 55.59920577639331), (37.73939925396728, 55.596314303136... | {"source_file": "cell-towers.md"} | [
0.0812523290514946,
-0.0135088711977005,
-0.0046395291574299335,
-0.0127014284953475,
-0.043875548988580704,
-0.05505368486046791,
-0.02876979112625122,
-0.04606189206242561,
-0.03329218551516533,
0.023576565086841583,
0.012154689989984035,
-0.038020189851522446,
0.034722261130809784,
-0.0... |
8d156be0-6a54-4bf3-9c76-2951493be9bd | (37.413344899475064, 55.690896881757396), (37.41171432275391, 55.69264232162232), (37.40948282275393, 55.69455101638112), (37.40703674603271, 55.69638690385348), (37.39607169577025, 55.70451821283731), (37.38952706878662, 55.70942491932811),
(37.387778313491815, 55.71149057784176), (37.39049275399779, 55.71419814298992... | {"source_file": "cell-towers.md"} | [
0.08191739767789841,
-0.02638583816587925,
0.00357318134047091,
-0.013556545600295067,
-0.05037754774093628,
-0.04936935380101204,
-0.028960229828953743,
-0.04665452986955643,
-0.02222304977476597,
0.02936490997672081,
0.007445760071277618,
-0.03251029923558235,
0.040249645709991455,
-0.02... |
dfb426db-b7e4-4db0-a380-ccc62ae76281 | (37.463383999999984, 55.88252729504517), (37.46682797486874, 55.88294937719063), (37.470014457672086, 55.88361266759345), (37.47751410450743, 55.88546991372396), (37.47860317658232, 55.88534929207307), (37.48165826025772, 55.882563306475106),
(37.48316434442331, 55.8815803226785), (37.483831555817645, 55.88242761279331... | {"source_file": "cell-towers.md"} | [
0.08719641715288162,
-0.011925231665372849,
0.012036904692649841,
-0.016739433631300926,
-0.043427132070064545,
-0.057577431201934814,
-0.04125277325510979,
-0.05233825743198395,
-0.037566810846328735,
0.02334521897137165,
0.0164404958486557,
-0.03470759466290474,
0.03181084990501404,
-0.0... |
a0be66c7-ad53-4e3e-9df6-730188eec147 | Check how many cell towers are in Moscow:
sql
SELECT count() FROM cell_towers
WHERE pointInPolygon((lon, lat), (SELECT * FROM moscow))
```response
ββcount()ββ
β 310463 β
βββββββββββ
1 rows in set. Elapsed: 0.067 sec. Processed 43.28 million rows, 692.42 MB (645.83 million rows/s., 10.33 GB/s.)
```
Review of t... | {"source_file": "cell-towers.md"} | [
0.08507370948791504,
-0.026456011459231377,
-0.05784204602241516,
-0.018691306933760643,
-0.04676557704806328,
0.004788650199770927,
-0.013632271438837051,
0.055255990475416183,
0.006452913396060467,
0.0010862122289836407,
0.014387108385562897,
-0.024791033938527107,
0.03452922776341438,
0... |
2247e73c-f164-4407-899a-01c255b78ab3 | Add your connection details {#add-your-connection-details}
:::tip
Make sure that you set
SSL
on when connecting to ClickHouse Cloud or other ClickHouse systems that enforce the use of SSL.
:::
Add the table
cell_towers
as a Superset
dataset
{#add-the-table-cell_towers-as-a-superset-dataset}
In Superset ... | {"source_file": "cell-towers.md"} | [
0.005744066089391708,
-0.06504840403795242,
-0.02050853706896305,
0.034947339445352554,
-0.07664718478918076,
-0.004370562732219696,
-0.0293679591268301,
-0.010382835753262043,
0.025884907692670822,
-0.002376129385083914,
0.03616565465927124,
-0.03525833785533905,
0.017198780551552773,
0.0... |
942e00d2-1234-422d-9594-59f32520f746 | description: 'Over 20 billion records of data from Sensor.Community, a contributors-driven
global sensor network that creates Open Environmental Data.'
sidebar_label: 'Environmental sensors data'
slug: /getting-started/example-datasets/environmental-sensors
title: 'Environmental Sensors Data'
doc_type: 'guide'
keywor... | {"source_file": "environmental-sensors.md"} | [
-0.007967624813318253,
0.002928406000137329,
-0.023277495056390762,
0.0385453887283802,
0.12130209803581238,
-0.1168135479092598,
0.03823815658688545,
0.016018306836485863,
-0.019732307642698288,
0.030689025297760963,
0.0985906794667244,
-0.03977949917316437,
0.05598532035946846,
-0.018237... |
4fb839c2-30c2-43e5-a7fd-5afa65dd7168 | The data is in CSV files but uses a semi-colon for the delimiter. The rows look like:
response
ββsensor_idββ¬βsensor_typeββ¬βlocationββ¬ββββlatββ¬ββββlonββ¬βtimestampββββββββββββ¬ββpressureββ¬βaltitudeββ¬βpressure_sealevelββ¬βtemperatureββ
β 9119 β BMP180 β 4594 β 50.994 β 7.126 β 2019-06-01T00:00:00 β 10147... | {"source_file": "environmental-sensors.md"} | [
-0.010754355229437351,
0.017192229628562927,
0.01068973634392023,
0.004291664343327284,
0.01733616180717945,
-0.09533410519361496,
-0.006789687089622021,
-0.03823813796043396,
0.023079311475157738,
0.0678306519985199,
0.06450958549976349,
-0.0356740802526474,
-0.03786433860659599,
-0.08025... |
3bf4e315-a0a7-4248-ac1c-14133592c9eb | This query will take a while - it's about 1.67T of data uncompressed:
sql
INSERT INTO sensors
SELECT *
FROM s3Cluster(
'default',
'https://clickhouse-public-datasets.s3.amazonaws.com/sensors/monthly/*.csv.zst',
'CSVWithNames',
$$ sensor_id UInt16,
sensor_type String,
... | {"source_file": "environmental-sensors.md"} | [
0.02648819424211979,
-0.018099956214427948,
-0.07313337177038193,
0.025117924436926842,
0.08987828344106674,
-0.05396179482340813,
-0.013339253142476082,
-0.05106313154101372,
-0.03070005215704441,
0.025466838851571083,
0.003327783662825823,
-0.14608101546764374,
0.061961136758327484,
-0.1... |
7d2e426f-f5dd-4da1-827e-ec4dda0406df | slug: /guides/developer/alternative-query-languages
sidebar_label: 'Alternative query languages'
title: 'Alternative Query Languages'
description: 'Use alternative query languages in ClickHouse'
keywords: ['alternative query languages', 'query dialects', 'MySQL dialect', 'PostgreSQL dialect', 'developer guide']
doc_typ... | {"source_file": "alternative-query-languages.md"} | [
0.003374802879989147,
-0.03538310155272484,
-0.006460558623075485,
0.010725421831011772,
-0.17117859423160553,
0.0025061562191694975,
0.03869527578353882,
-0.028233801946043968,
-0.05804893374443054,
-0.047816358506679535,
-0.021636689081788063,
-0.047394782304763794,
0.04585724323987961,
... |
09978dfe-5cee-469c-930e-8291ee0ac90e | slug: /guides/developer/debugging-memory-issues
sidebar_label: 'Debugging memory issues'
sidebar_position: 1
description: 'Queries to help you debug memory issues.'
keywords: ['memory issues']
title: 'Debugging memory issues'
doc_type: 'guide'
Debugging memory issues {#debugging-memory-issues}
When encountering m... | {"source_file": "debugging-memory-issues.md"} | [
0.11287976056337357,
-0.04110516607761383,
-0.08620326966047287,
0.07075314223766327,
-0.017982831224799156,
-0.02420179918408394,
0.038531024008989334,
0.09228302538394928,
-0.09666192531585693,
0.08158181607723236,
-0.03509540110826492,
0.0037684794515371323,
-0.009832006879150867,
-0.04... |
0ad201da-3ff8-4efa-9310-94be982fb4de | slug: /guides/developer/ttl
sidebar_label: 'TTL (Time To Live)'
sidebar_position: 2
keywords: ['ttl', 'time to live', 'clickhouse', 'old', 'data']
description: 'TTL (time-to-live) refers to the capability of having rows or columns moved, deleted, or rolled up after a certain interval of time has passed.'
title: 'Manage... | {"source_file": "ttl.md"} | [
-0.06457996368408203,
-0.018708348274230957,
-0.0055095055140554905,
0.027328569442033768,
0.04413516819477081,
0.0037431151140481234,
-0.03259635344147682,
-0.07084684073925018,
0.09607066214084625,
0.003206728957593441,
0.0727570503950119,
0.0760730504989624,
0.02966422587633133,
-0.0157... |
8b3d2a23-1a72-4eef-9e90-d163cb14bdb9 | So by default, your TTL rules will be applied to your table at least once every 4 hours. Just modify the settings above if you need your TTL rules applied more frequently.
:::note
Not a great solution (or one that we recommend you use frequently), but you can also force a merge using
OPTIMIZE
:
sql
OPTIMIZE TABLE ... | {"source_file": "ttl.md"} | [
0.005991352256387472,
0.007635961752384901,
0.04670993238687515,
0.009260912425816059,
-0.12690554559230804,
-0.07763881981372833,
0.041411370038986206,
0.010569493286311626,
0.05593348294496536,
0.008010836318135262,
0.04414895549416542,
0.046550583094358444,
-0.007944476790726185,
-0.016... |
b138fd40-447d-4e2d-9a1e-40da89466378 | We added two fields to store the aggregated results:
max_hits
and
sum_hits
Setting the default value of
max_hits
and
sum_hits
to
hits
is necessary for our logic to work, based on how the
SET
clause is defined
Implementing a hot/warm/cold architecture {#implementing-a-hotwarmcold-architecture}
:::no... | {"source_file": "ttl.md"} | [
-0.024277303367853165,
-0.03218269720673561,
-0.0014165060129016638,
0.05640473589301109,
-0.07523021847009659,
-0.013632779009640217,
-0.03207400068640709,
0.0011422935640439391,
-0.023561010137200356,
0.03918449580669403,
0.014830865897238255,
-0.026735585182905197,
0.09558729827404022,
... |
8b016616-9264-4183-a9ac-cb88364429a7 | And...let's verify the volumes:
sql
SELECT
volume_name,
disks
FROM system.storage_policies
response
ββvolume_nameββ¬βdisksββββββββββ
β default β ['default'] β
β hot_volume β ['hot_disk'] β
β warm_volume β ['warm_disk'] β
β cold_volume β ['cold_disk'] β
βββββββββββββββ΄ββββββββββββββββ
Now we wil... | {"source_file": "ttl.md"} | [
0.0033359741792082787,
-0.0069966441951692104,
0.0005188024369999766,
0.060990579426288605,
-0.026290997862815857,
-0.07892069965600967,
0.02105298638343811,
-0.011732149869203568,
-0.02848009392619133,
0.01839235983788967,
0.017816629260778427,
-0.05535617470741272,
0.10718882828950882,
0... |
17cd62a4-68a1-492d-9d2d-d528c8e919ae | sidebar_label: 'Stored procedures & query parameters'
sidebar_position: 19
keywords: ['clickhouse', 'stored procedures', 'prepared statements', 'query parameters', 'UDF', 'parameterized views']
description: 'Guide on stored procedures, prepared statements, and query parameters in ClickHouse'
slug: /guides/developer/sto... | {"source_file": "stored-procedures-and-prepared-statements.md"} | [
0.0331437885761261,
-0.013630622997879982,
-0.1268039345741272,
0.05200204253196716,
-0.07677546888589859,
-0.00827089510858059,
0.03437928482890129,
0.08433075994253159,
-0.11341986805200577,
-0.0016192594775930047,
0.03948166221380234,
0.008352609351277351,
0.10203895717859268,
-0.092744... |
6dfec880-33aa-4b90-b894-8f1604a24692 | SELECT
product_name,
price,
price_tier(price) AS tier
FROM products;
```
```sql
-- String manipulation
CREATE FUNCTION format_phone AS (phone) ->
concat('(', substring(phone, 1, 3), ') ',
substring(phone, 4, 3), '-',
substring(phone, 7, 4));
SELECT format_phone('5551234567');
-... | {"source_file": "stored-procedures-and-prepared-statements.md"} | [
-0.0447407104074955,
-0.009576643817126751,
-0.06945580989122391,
0.0021314783953130245,
-0.10621008276939392,
-0.05628172680735588,
0.06420671939849854,
0.11184248328208923,
-0.03378724679350853,
0.006366100627928972,
0.0921124815940857,
-0.054712437093257904,
0.10073798149824142,
-0.0673... |
046ced20-60d1-4579-abf5-039b92f160fb | Common use cases {#common-use-cases}
Dynamic date range filtering
User-specific data slicing
Multi-tenant data access
Report templates
Data masking
```sql
-- More complex parameterized view
CREATE VIEW top_products_by_category AS
SELECT
category,
product_name,
revenue,
rank
FROM (
SE... | {"source_file": "stored-procedures-and-prepared-statements.md"} | [
0.028773874044418335,
0.05630745738744736,
-0.033204007893800735,
0.014274084940552711,
-0.08017648756504059,
0.05124024674296379,
0.015619806945323944,
0.10125456005334854,
-0.05793217569589615,
-0.0381852351129055,
-0.0020814789459109306,
-0.04597287252545357,
0.07928628474473953,
-0.013... |
5eeab68c-6794-4820-84b9-efa71d8d12b6 | Refreshable materialized views {#refreshable-materialized-views}
For scheduled batch processing (like nightly stored procedures):
```sql
-- Automatically refresh every day at 2 AM
CREATE MATERIALIZED VIEW monthly_sales_report
REFRESH EVERY 1 DAY OFFSET 2 HOUR
AS SELECT
toStartOfMonth(order_date) AS month,
r... | {"source_file": "stored-procedures-and-prepared-statements.md"} | [
-0.049442630261182785,
-0.035570766776800156,
-0.10135946422815323,
0.04151482880115509,
-0.12559647858142853,
-0.022820688784122467,
-0.016717396676540375,
0.014650789089500904,
-0.024031829088926315,
0.05902915820479393,
-0.014740632846951485,
0.019023440778255463,
0.06320346146821976,
-... |
96111e3a-fd3b-442c-a702-ef495d1f576b | -- Check if customer should be upgraded
IF v_previous_orders + 1 >= 10 AND v_customer_tier = 'bronze' THEN
UPDATE customers SET tier = 'silver' WHERE customer_id = p_customer_id;
SET p_status = 'ORDER_COMPLETE_TIER_UPGRADED_SILVER';
ELSEIF v_previous_orders + 1 >= 50 AND v_customer_tier = 'silver' THEN
UPDA... | {"source_file": "stored-procedures-and-prepared-statements.md"} | [
-0.05911429598927498,
0.02258319966495037,
-0.0057139042764902115,
-0.0098105538636446,
-0.15021884441375732,
-0.008565425872802734,
0.030072836205363274,
0.01822059601545334,
-0.04708941653370857,
0.030750103294849396,
0.10068181902170181,
-0.0342581532895565,
0.06720725446939468,
-0.1137... |
779d4fa8-15f3-44de-896b-b188c91de856 | # Step 4: Calculate new customer statistics
new_order_count = previous_orders + 1
# For analytics databases, prefer INSERT over UPDATE
# This uses a ReplacingMergeTree pattern
client.command(
"""
INSERT INTO customers (customer_id, tier, total_orders, last_order_date,
update_time)
... | {"source_file": "stored-procedures-and-prepared-statements.md"} | [
-0.09665478020906448,
0.06119813397526741,
-0.01844063773751259,
0.05251779034733772,
-0.15836729109287262,
0.022460296750068665,
0.022527508437633514,
0.034342776983976364,
-0.003367453580722213,
0.01923614740371704,
0.10467489808797836,
-0.025192467495799065,
0.112361378967762,
-0.073513... |
18bd9340-019b-412d-a48f-34c3e082a76f | Updates
- MySQL uses
UPDATE
statements. ClickHouse prefers
INSERT
with
ReplacingMergeTree
or
CollapsingMergeTree
for mutable data
Variables and state
- MySQL stored procedures can declare variables (
DECLARE v_discount
). With ClickHouse, manage state in your application code
Error handling
- MySQL suppo... | {"source_file": "stored-procedures-and-prepared-statements.md"} | [
-0.013298062607645988,
-0.010578842833638191,
-0.0349380262196064,
0.04048348218202591,
-0.10898742079734802,
-0.081621453166008,
0.05884135514497757,
0.04994037747383118,
-0.0215937327593565,
0.03174961730837822,
-0.0032627535983920097,
-0.006232106126844883,
0.08571578562259674,
-0.10886... |
3266b6cd-9d12-4ff4-8a1e-9a4c71cffe77 | -- Insert sample data for multiple users and events
INSERT INTO user_events (event_id, user_id, event_name, event_date, event_timestamp) VALUES
(1, 12345, 'page_view', '2024-01-05', '2024-01-05 10:30:00'),
(2, 12345, 'page_view', '2024-01-05', '2024-01-05 10:35:00'),
(3, 12345, 'add_to_cart', '2024-01-05', '2024-01-05 ... | {"source_file": "stored-procedures-and-prepared-statements.md"} | [
0.004556548316031694,
-0.016244987025856972,
0.002418385585770011,
0.05017499998211861,
-0.05695350468158722,
0.012518391013145447,
0.054073795676231384,
-0.009437035769224167,
-0.010574453510344028,
-0.019801462069153786,
0.08401068300008774,
-0.04333430528640747,
-0.05240783840417862,
-0... |
e3bdde25-ac95-4c51-a927-cc35193bf8b0 | -- 3. Create a table for array tests
CREATE TABLE IF NOT EXISTS products (
id UInt32,
name String
) ENGINE = Memory;
INSERT INTO products VALUES (1, 'Laptop'), (2, 'Monitor'), (3, 'Mouse'), (4, 'Keyboard');
-- 4. Create a table for Map (struct-like) tests
CREATE TABLE IF NOT EXISTS accounts (
user_id UInt... | {"source_file": "stored-procedures-and-prepared-statements.md"} | [
0.07529185712337494,
0.10615254938602448,
-0.07726244628429413,
-0.02746420167386532,
-0.10343825072050095,
0.011064799502491951,
0.07234880328178406,
0.058129165321588516,
-0.14860579371452332,
0.0224987231194973,
0.09673674404621124,
-0.11198222637176514,
0.0799669623374939,
-0.067442551... |
e66e780d-a32e-4775-b00f-1665009a4bc4 | -- β Multiple statements
{statements: String}; -- NOT SUPPORTED
```
Security best practices {#security-best-practices}
Always use query parameters for user input:
```python
β SAFE - Uses parameters
user_input = request.get('user_id')
result = client.query(
"SELECT * FROM orders WHERE user_id = {uid: UInt... | {"source_file": "stored-procedures-and-prepared-statements.md"} | [
-0.02103213407099247,
0.11376088857650757,
0.003865812672302127,
0.017013277858495712,
-0.0799039751291275,
0.02389511466026306,
0.044968295842409134,
0.05914413183927536,
-0.05570331960916519,
-0.07032836973667145,
0.01437433436512947,
0.03305807709693909,
0.10130943357944489,
-0.03786708... |
dc76ba4a-b992-49c2-93fb-381e17e1aa44 | :::
For more details, see the
MySQL Interface documentation
and the
blog post on MySQL support
.
Summary {#summary}
ClickHouse alternatives to stored procedures {#summary-stored-procedures}
| Traditional Stored Procedure Pattern | ClickHouse Alternative |
... | {"source_file": "stored-procedures-and-prepared-statements.md"} | [
-0.029318129643797874,
-0.0220935121178627,
-0.08525171875953674,
0.030378852039575577,
-0.11095110327005386,
-0.039467327296733856,
-0.025260167196393013,
0.08195998519659042,
0.010165276005864143,
0.09411213546991348,
0.005864151753485203,
-0.0405522845685482,
0.13771472871303558,
-0.056... |
2a41942a-7ae3-4d19-b894-dd33273fec04 | slug: /guides/developer/time-series-filling-gaps
sidebar_label: 'Time Series - Gap Fill'
sidebar_position: 10
description: 'Filling gaps in time-series data.'
keywords: ['time series', 'gap fill']
title: 'Filling gaps in time-series data'
doc_type: 'guide'
Filling gaps in time-series data
When working with time-s... | {"source_file": "time-series-filling-gaps.md"} | [
-0.09230935573577881,
0.052086614072322845,
0.015079556964337826,
0.036528900265693665,
-0.026428550481796265,
-0.0009487329516559839,
-0.022396817803382874,
0.06598414480686188,
-0.0033397015649825335,
-0.03839379921555519,
0.038634270429611206,
-0.02126338705420494,
0.05101817473769188,
... |
1a4ab474-7e90-46d5-a159-ff117729858c | WITH FILL {#with-fill}
We can use the
WITH FILL
clause to fill in these gaps.
We'll also specify the
STEP
, which is the size of the gaps to fill.
This defaults to 1 second for
DateTime
types, but we'd like to fill gaps of 100ms in length, so let's an interval of 100ms as our step value:
sql
SELECT
toStart... | {"source_file": "time-series-filling-gaps.md"} | [
-0.043801866471767426,
0.03438166528940201,
0.07324202358722687,
0.02690792642533779,
-0.052324797958135605,
0.05945141986012459,
-0.02871505729854107,
0.04854103550314903,
0.009052051231265068,
0.007862257771193981,
-0.02401258423924446,
-0.06082388386130333,
0.03705452382564545,
-0.02456... |
8286ab62-0834-44c0-974e-f35d74d182dc | TO
is not inclusive, so we'll add a small amount to the end time to make sure that it's included:
sql
SELECT
toStartOfInterval(timestamp, toIntervalMillisecond(100)) AS bucket,
count() AS count
FROM MidJourney.images
WHERE (timestamp >= {start:String}) AND (timestamp <= {end:String})
GROUP BY ALL
ORDER BY bu... | {"source_file": "time-series-filling-gaps.md"} | [
0.016519932076334953,
0.01309877261519432,
0.06240837648510933,
0.0650663673877716,
0.0010626842267811298,
0.017494460567831993,
-0.00974984560161829,
0.03568728640675545,
0.039753545075654984,
0.02109546586871147,
-0.010777573101222515,
-0.05804100260138512,
0.053306594491004944,
-0.00510... |
ab9128fd-b7bf-4389-a725-081d8815c967 | response
βββββββββββββββββββbucketββ¬βcountββ¬βcumulativeββ
β 2023-03-24 00:24:03.000 β 0 β 0 β
β 2023-03-24 00:24:03.100 β 0 β 0 β
β 2023-03-24 00:24:03.200 β 0 β 0 β
β 2023-03-24 00:24:03.300 β 0 β 0 β
β 2023-03-24 00:24:03.400 β 0 β 0 β
β 2023-03-24 00:2... | {"source_file": "time-series-filling-gaps.md"} | [
-0.032954610884189606,
0.024199003353714943,
-0.020074812695384026,
0.021481815725564957,
-0.0375993587076664,
-0.07484956830739975,
0.02150077559053898,
-0.04740770161151886,
0.009106731973588467,
0.03506476432085037,
0.04937591403722763,
-0.0710916817188263,
0.017696456983685493,
-0.0053... |
a9a734e9-5e00-4f23-898c-1ecc62fcbcc5 | response
βββββββββββββββββββbucketββ¬βcountββ¬βcumulativeββ
β 2023-03-24 00:24:03.000 β 0 β 0 β
β 2023-03-24 00:24:03.100 β 0 β 0 β
β 2023-03-24 00:24:03.200 β 0 β 0 β
β 2023-03-24 00:24:03.300 β 0 β 0 β
β 2023-03-24 00:24:03.400 β 0 β 0 β
β 2023-03-24 00:2... | {"source_file": "time-series-filling-gaps.md"} | [
-0.03340337797999382,
0.019577793776988983,
-0.020606447011232376,
0.013767944648861885,
-0.03621139004826546,
-0.06884034723043442,
0.019268611446022987,
-0.05054209753870964,
0.005333764478564262,
0.0421278290450573,
0.05491892620921135,
-0.06945148855447769,
0.01968749612569809,
-0.0069... |
b50d3a43-0c9d-484f-9be1-91709fb89e58 | response
βββββββββββββββββββbucketββ¬βcountββ¬βcumulativeββ¬βbarChartββ
β 2023-03-24 00:24:03.000 β 0 β 0 β β
β 2023-03-24 00:24:03.100 β 0 β 0 β β
β 2023-03-24 00:24:03.200 β 0 β 0 β β
β 2023-03-24 00:24:03.300 β 0 β 0 β β
β 2023-03-2... | {"source_file": "time-series-filling-gaps.md"} | [
-0.0358058400452137,
0.01498372945934534,
-0.020898709073662758,
0.013728918507695198,
-0.03708581626415253,
-0.06702054291963577,
0.024163318797945976,
-0.05532390996813774,
-0.0005097202956676483,
0.045774251222610474,
0.05480216443538666,
-0.06376297026872635,
0.024870552122592926,
-0.0... |
a262d811-bfc9-4f17-9f9a-a139da6924b9 | slug: /guides/developer/deduplicating-inserts-on-retries
title: 'Deduplicating Inserts on Retries'
description: 'Preventing duplicate data when retrying insert operations'
keywords: ['deduplication', 'deduplicate', 'insert retries', 'inserts']
doc_type: 'guide'
Insert operations can sometimes fail due to errors suc... | {"source_file": "deduplicating-inserts-on-retries.md"} | [
-0.08594169467687607,
-0.07647299021482468,
0.02797812595963478,
0.024403076618909836,
-0.06148282811045647,
-0.07767978310585022,
-0.03471725434064865,
-0.08648955076932907,
0.0007888441323302686,
0.01837781071662903,
0.11222560703754425,
-0.007084608543664217,
0.0822327584028244,
-0.0774... |
a5e74ee2-ac58-46e1-9104-f78ed41e714c | How insert deduplication works {#how-insert-deduplication-works}
When data is inserted into ClickHouse, it splits data into blocks based on the number of rows and bytes.
For tables using
*MergeTree
engines, each block is assigned a unique
block_id
, which is a hash of the data in that block. This
block_id
is u... | {"source_file": "deduplicating-inserts-on-retries.md"} | [
-0.06403052061796188,
-0.08616644889116287,
0.03400914743542671,
0.0072028664872050285,
-0.05149868130683899,
-0.10194317996501923,
0.03396274894475937,
-0.031081542372703552,
0.05198797956109047,
0.017983635887503624,
0.09596031159162521,
0.007100086193531752,
0.07238931953907013,
-0.1110... |
4c397fa5-9a31-4863-8be3-40db303e06a1 | When inserting blocks into tables under materialized views, ClickHouse calculates the
block_id
by hashing a string that combines the
block_id
s from the source table and additional identifiers. This ensures accurate deduplication within materialized views, allowing data to be distinguished based on its original inse... | {"source_file": "deduplicating-inserts-on-retries.md"} | [
-0.10084320604801178,
-0.04505837336182594,
-0.024941835552453995,
-0.0221952423453331,
-0.06662753969430923,
-0.06211109459400177,
-0.03030429594218731,
-0.05738792195916176,
0.047135427594184875,
-0.020437249913811684,
0.03837375342845917,
-0.020662635564804077,
0.03327876701951027,
-0.0... |
fa413b26-413c-4ff5-a2e0-6474049bf3d5 | Here we see that when we retry the inserts, all data is deduplicated. Deduplication works for both the
dst
and
mv_dst
tables.
Identical blocks on insertion {#identical-blocks-on-insertion}
``sql
CREATE TABLE dst
(
key
Int64,
value` String
)
ENGINE = MergeTree
ORDER BY tuple()
SETTINGS non_replicated_deduplicati... | {"source_file": "deduplicating-inserts-on-retries.md"} | [
-0.09200529009103775,
-0.06608344614505768,
0.06363231688737869,
-0.025582678616046906,
-0.046381428837776184,
-0.11948801577091217,
-0.04318191111087799,
0.03009464219212532,
0.020213047042489052,
0.022615423426032066,
0.08990716189146042,
0.018215959891676903,
0.01856185309588909,
-0.125... |
3a5a75d3-aa30-4440-b460-cec2a71e47c6 | ββ'from dst'ββ¬βkeyββ¬βvalueββ¬β_partββββββ
β from dst β 0 β A β all_2_2_0 β
β from dst β 0 β A β all_3_3_0 β
ββββββββββββββ΄ββββββ΄ββββββββ΄ββββββββββββ
```
That insertion is also deduplicated even though it contains different inserted data. Note that
insert_deduplication_token
has higher priority: Click... | {"source_file": "deduplicating-inserts-on-retries.md"} | [
-0.102481409907341,
-0.0920657068490982,
0.0007028327090665698,
-0.008099595084786415,
-0.07451651990413666,
-0.0666969045996666,
-0.0010134036419913173,
-0.02331509441137314,
0.02536202035844326,
0.0230778269469738,
0.10148047655820847,
-0.022327879443764687,
0.04233480617403984,
-0.10105... |
8772be09-1ea2-4680-a394-12401ce969ae | CREATE MATERIALIZED VIEW mv_second
TO mv_dst
AS SELECT
0 AS key,
value AS value
FROM dst;
SET deduplicate_blocks_in_dependent_materialized_views=1;
select 'first attempt';
INSERT INTO dst VALUES (1, 'A');
SELECT
'from dst',
*,
_part
FROM dst
ORDER by all;
ββ'from dst'ββ¬βkeyββ¬βvalueββ¬β_part... | {"source_file": "deduplicating-inserts-on-retries.md"} | [
-0.09321294724941254,
-0.10494853556156158,
0.03159638121724129,
-0.032827846705913544,
-0.07957469671964645,
-0.05825453996658325,
0.024087626487016678,
0.02458217553794384,
0.028518175706267357,
0.028444349765777588,
0.08142166584730148,
-0.004686996340751648,
0.014780621975660324,
-0.05... |
a95ef652-b29b-41da-9575-2683440933e4 | slug: /guides/developer/dynamic-column-selection
sidebar_label: 'Dynamic column selection'
title: 'Dynamic column selection'
description: 'Use alternative query languages in ClickHouse'
doc_type: 'guide'
keywords: ['dynamic column selection', 'regular expressions', 'APPLY modifier', 'advanced queries', 'developer guide... | {"source_file": "dynamic-column-selection.md"} | [
0.006221771240234375,
0.002835232065990567,
-0.009159100241959095,
0.07201717793941498,
-0.012972600758075714,
-0.04328332841396332,
0.06751154363155365,
0.016090085729956627,
-0.03334709629416466,
-0.025377243757247925,
-0.007934914901852608,
-0.04312571883201599,
-0.03083956614136696,
-0... |
adfacd09-1a34-42a7-bb42-1b4ffbb1aab4 | Selecting multiple patterns {#selecting-multiple-patterns}
We can combine multiple column patterns in a single query:
sql
SELECT
COLUMNS('.*_amount'),
COLUMNS('.*_date.*')
FROM nyc_taxi.trips
LIMIT 5;
Try this query in the SQL playground
text
ββfare_amountββ¬βtip_amountββ¬βtolls_amountββ¬βtotal_am... | {"source_file": "dynamic-column-selection.md"} | [
0.026070857420563698,
-0.046109020709991455,
0.0621783472597599,
0.08540148288011551,
-0.023455284535884857,
-0.021024199202656746,
0.09192119538784027,
-0.03159573674201965,
-0.06506457179784775,
-0.005622918251901865,
0.04839582368731499,
-0.038279939442873,
-0.06296421587467194,
0.05411... |
15090e0c-04ec-457f-8b00-ffcdacf9cf49 | sql
SELECT COLUMNS('.*_amount|fee|tax') APPLY(avg) APPLY(round)
FROM nyc_taxi.trips;
Try this query in the SQL playground
text
ββround(avg(fare_amount))ββ¬βround(avg(mta_tax))ββ¬βround(avg(tip_amount))ββ¬βround(avg(tolls_amount))ββ¬βround(avg(ehail_fee))ββ¬βround(avg(total_amount))ββ
1. β 12 ... | {"source_file": "dynamic-column-selection.md"} | [
0.03305928036570549,
0.002673738868907094,
0.012859963811933994,
0.026042604818940163,
-0.018296359106898308,
-0.056821759790182114,
0.08475182950496674,
0.04811432585120201,
-0.007002693600952625,
0.04502836987376213,
0.03780714422464371,
-0.13173142075538635,
0.0020732986740767956,
-0.01... |
1a9e55fb-2f87-47fb-89b4-136777104066 | Excluding columns {#excluding-columns}
We can also choose to exclude a field by using the
EXCEPT
modifier. For example, to remove the
tolls_amount
column, we would write the following query:
sql
FROM nyc_taxi.trips
SELECT
COLUMNS('.*_amount|fee|tax') EXCEPT(tolls_amount)
REPLACE(
total_amount*2 AS to... | {"source_file": "dynamic-column-selection.md"} | [
0.039174582809209824,
0.07940471917390823,
0.0637374073266983,
0.043046824634075165,
0.017467167228460312,
-0.039043862372636795,
0.05758379027247429,
-0.027693895623087883,
-0.0196936447173357,
0.04939626157283783,
0.081980861723423,
-0.09300052374601364,
0.028112344443798065,
-0.07779847... |
147cc125-7582-481f-8cf0-b40525f94f1e | slug: /guides/developer/cascading-materialized-views
title: 'Cascading Materialized Views'
description: 'How to use multiple materialized views from a source table.'
keywords: ['materialized view', 'aggregation']
doc_type: 'guide'
Cascading materialized views
This example demonstrates how to create a materialized... | {"source_file": "cascading-materialized-views.md"} | [
-0.03326321020722389,
-0.08525217324495316,
-0.037118349224328995,
0.017184145748615265,
-0.10154186934232712,
-0.07985465973615646,
-0.0662071630358696,
-0.03221581131219864,
-0.029136188328266144,
0.009134300984442234,
-0.006708646193146706,
-0.07880470156669617,
0.08537130802869797,
-0.... |
4582ca7d-8b7f-4de2-b4a7-f3f519914402 | Yearly aggregated table and materialized view {#yearly-aggregated-table-and-materialized-view}
Now we will create the second Materialized view that will be linked to our previous target table
monthly_aggregated_data
.
First, we will create a new target table that will store the sum of views aggregated by year for ... | {"source_file": "cascading-materialized-views.md"} | [
-0.017553631216287613,
-0.02754240296781063,
-0.022075925022363663,
0.05624347925186157,
-0.05904817581176758,
-0.03447756543755531,
-0.027319684624671936,
-0.06660230457782745,
-0.06706679612398148,
0.022585678845643997,
0.04496501013636589,
-0.10473491251468658,
0.07933732122182846,
-0.0... |
e17d402b-0edd-4766-abfe-5e59de47a544 | Results {#results}
If you try to query the target table by selecting the
sumCountViews
field, you will see the binary representation (in some terminals), as the value is not stored as a number but as an AggregateFunction type.
To get the final result of the aggregation you should use the
-Merge
suffix.
You can ... | {"source_file": "cascading-materialized-views.md"} | [
0.0014082139823585749,
-0.045589640736579895,
-0.046092137694358826,
0.10466215014457703,
-0.07896380126476288,
0.020773179829120636,
0.10095921158790588,
0.004847686272114515,
0.030842745676636696,
-0.000031480602046940476,
0.0025445609353482723,
-0.10895318537950516,
0.05402909219264984,
... |
c9e55bc4-691a-4e72-8014-ed6b56a3dfbe | ``sql
CREATE TABLE analytics.impressions
(
event_time
DateTime,
domain_name` String
) ENGINE = MergeTree ORDER BY (domain_name, event_time)
;
CREATE TABLE analytics.clicks
(
event_time
DateTime,
domain_name
String
) ENGINE = MergeTree ORDER BY (domain_name, event_time)
;
```
Then create the
Target
tab... | {"source_file": "cascading-materialized-views.md"} | [
0.014372388832271099,
-0.06848099827766418,
0.009548977948725224,
0.0752609595656395,
-0.061849042773246765,
-0.05808163061738014,
0.07056303322315216,
0.014648672193288803,
-0.007795768324285746,
-0.00469801714643836,
0.03240792453289032,
-0.10490234196186066,
0.03469425439834595,
-0.0537... |
95f6dfff-286e-4eef-b09c-41a18f7b5627 | slug: /guides/developer/on-the-fly-mutations
sidebar_label: 'On-the-fly mutation'
title: 'On-the-fly Mutations'
keywords: ['On-the-fly mutation']
description: 'Provides a description of on-the-fly mutations'
doc_type: 'guide'
On-the-fly mutations {#on-the-fly-mutations}
When on-the-fly mutations are enabled, upda... | {"source_file": "on-fly-mutations.md"} | [
0.0064336396753787994,
-0.028670595958828926,
-0.0018442199798300862,
0.031299859285354614,
-0.00010036824096459895,
-0.06883173435926437,
0.0019118757918477058,
0.014949381351470947,
-0.023790471255779266,
0.002989289117977023,
0.051775090396404266,
0.005307989194989204,
-0.0004199210088700... |
dc2c38fb-3cb6-4c4f-9e95-1761c25496c8 | We suggest enabling the setting
apply_mutations_on_fly
together with other
MergeTree
-level settings such as
number_of_mutations_to_throw
and
number_of_mutations_to_delay
to restrict the infinite growth of unmaterialized mutations.
Support for subqueries and non-deterministic functions {#support-for-subqueries... | {"source_file": "on-fly-mutations.md"} | [
-0.0538400337100029,
0.0014241208555176854,
0.013027518056333065,
-0.009741267189383507,
0.004636503290385008,
-0.11961019039154053,
-0.043929412961006165,
0.019544692710042,
0.02658836357295513,
0.021611010655760765,
0.034658968448638916,
-0.005437992978841066,
0.029811471700668335,
-0.05... |
c73f9919-b86e-48b9-8392-f2cb17ab2d83 | slug: /guides/developer/deduplication
sidebar_label: 'Deduplication strategies'
sidebar_position: 3
description: 'Use deduplication when you need to perform frequent upserts, updates and deletes.'
title: 'Deduplication Strategies'
keywords: ['deduplication strategies', 'data deduplication', 'upserts', 'updates and dele... | {"source_file": "deduplication.md"} | [
-0.12750567495822906,
0.012800696305930614,
-0.009150615893304348,
0.010783783160150051,
0.03259008750319481,
-0.11629161238670349,
-0.013928730972111225,
0.003435147227719426,
0.04253522679209709,
-0.0002763642405625433,
0.13068929314613342,
0.10899019241333008,
0.07941406965255737,
-0.12... |
0947814a-275f-4fad-8a1d-fb25410693d3 | sql
CREATE TABLE hackernews_rmt (
id UInt32,
author String,
comment String,
views UInt64
)
ENGINE = ReplacingMergeTree
PRIMARY KEY (author, id)
Let's insert two rows:
sql
INSERT INTO hackernews_rmt VALUES
(1, 'ricardo', 'This is post #1', 0),
(2, 'ch_fan', 'This is post #2', 0)
To update the... | {"source_file": "deduplication.md"} | [
-0.008830221369862556,
-0.04090164601802826,
-0.05485314875841141,
0.04667162895202637,
-0.03492244705557823,
-0.020624011754989624,
0.014889887534081936,
-0.06314469128847122,
0.02545202150940895,
0.0510576032102108,
0.08484233915805817,
-0.04900548234581947,
0.11248482018709183,
-0.10966... |
f2233308-0778-4df4-b3b3-982ea4c4eb60 | sql
SELECT
id,
author,
comment,
max(views)
FROM hackernews_rmt
GROUP BY (id, author, comment)
response
ββidββ¬βauthorβββ¬βcommentββββββββββ¬βmax(views)ββ
β 2 β ch_fan β This is post #2 β 250 β
β 1 β ricardo β This is post #1 β 150 β
ββββββ΄ββββββββββ΄ββββββββββββββββββ΄βββββββββββββ
Group... | {"source_file": "deduplication.md"} | [
-0.07006030529737473,
-0.07934335619211197,
-0.002115731593221426,
0.07973421365022659,
0.03309326618909836,
-0.05495031177997589,
0.009582418017089367,
-0.07289929687976837,
0.02406879886984825,
0.04146682471036911,
0.08606671541929245,
0.05120735615491867,
0.05428817868232727,
-0.1285045... |
cd7f7d2e-c5ce-4557-a440-c51466008525 | Let's add a row to the
hackernews_views
table. Since it is the only row for this primary key, we set its state to 1:
sql
INSERT INTO hackernews_views VALUES
(123, 'ricardo', 0, 1)
Now suppose we want to change the views column. You insert two rows: one that cancels the existing row, and one that contains the n... | {"source_file": "deduplication.md"} | [
-0.05792476609349251,
-0.06037087365984917,
-0.04430289939045906,
0.012480494566261768,
0.005737443920224905,
-0.037645500153303146,
0.06770548969507217,
-0.07045257836580276,
0.04183683544397354,
0.07632526010274887,
0.02217678353190422,
-0.04165824130177498,
0.06835033744573593,
-0.04845... |
f061b5bb-bd41-4d49-afd9-a40faef22a87 | It deletes each pair of rows that have the same primary key and version and different sign
The order that rows were inserted does not matter
Note that if the version column is not a part of the primary key, ClickHouse adds it to the primary key implicitly as the last field
You use the same type of logic when wr... | {"source_file": "deduplication.md"} | [
-0.02496792934834957,
-0.05188893899321556,
-0.006318721454590559,
0.0057354941964149475,
0.021375365555286407,
-0.049832895398139954,
0.03593096509575844,
-0.1596279889345169,
0.09147835522890091,
0.04927985370159149,
0.09572503715753555,
0.05702528357505798,
0.1072850376367569,
-0.142132... |
091779cb-dfc3-443d-a6fe-4a2e218e2c65 | slug: /guides/developer/overview
sidebar_label: 'Advanced guides overview'
description: 'Overview of the advanced guides'
title: 'Advanced Guides'
keywords: ['ClickHouse advanced guides', 'developer guides', 'query optimization', 'materialized views', 'deduplication', 'time series', 'query execution']
doc_type: 'guide'... | {"source_file": "index.md"} | [
-0.003765841480344534,
-0.033834703266620636,
-0.010881945490837097,
0.04289025440812111,
0.019334839656949043,
-0.03742704167962074,
-0.012271514162421227,
0.06569871306419373,
-0.08895357698202133,
0.02697325497865677,
0.008823845535516739,
0.0796399936079979,
-0.008018823340535164,
-0.0... |
e541bc6f-a107-4373-816a-e4c6b9238aaf | | Guide | Description ... | {"source_file": "index.md"} | [
-0.0489174909889698,
0.05097671225667,
-0.04641375318169594,
-0.026167131960392,
-0.03592504560947418,
0.04320058226585388,
-0.0045058587566018105,
0.014410771429538727,
-0.01142040453851223,
-0.06388410180807114,
0.05868655815720558,
0.02183864265680313,
-0.029123876243829727,
-0.06183888... |
3374f1aa-e848-41d1-8cfc-abc582485f90 | |
Filling gaps in time-series data
| A guide which provides insights into ClickHouse's capabilities for handling time-series data, including techniques for filling gaps in data to create a more complete and continuous representation of time-series information. ... | {"source_file": "index.md"} | [
-0.07709024846553802,
-0.002676451113075018,
-0.059487972408533096,
0.05924112722277641,
-0.05869435891509056,
-0.056976623833179474,
-0.03364238888025284,
0.026147961616516113,
-0.013521336950361729,
-0.02728315070271492,
-0.021179668605327606,
-0.03318547084927559,
-0.0005857395008206367,
... |
3fe2fa2d-ee7e-4960-a4df-908b4528f2a5 | slug: /guides/developer/lightweight-delete
title: 'Lightweight Delete'
keywords: ['lightweight delete']
description: 'Provides an overview of lightweight deletes in ClickHouse'
doc_type: 'reference'
import Content from '@site/docs/sql-reference/statements/delete.md'; | {"source_file": "lightweight-delete.md"} | [
-0.031236937269568443,
-0.004036429338157177,
-0.044891875237226486,
0.022028829902410507,
0.05726628005504608,
-0.07581993192434311,
0.0547761432826519,
-0.056266333907842636,
-0.008499984629452229,
-0.00504929618909955,
0.01859883777797222,
0.0092776445671916,
0.09251432120800018,
-0.029... |
49258673-c614-4547-b3c0-077b6a9fb216 | slug: /guides/replacing-merge-tree
title: 'ReplacingMergeTree'
description: 'Using the ReplacingMergeTree engine in ClickHouse'
keywords: ['replacingmergetree', 'inserts', 'deduplication']
doc_type: 'guide'
import postgres_replacingmergetree from '@site/static/images/migrations/postgres-replacingmergetree.png';
imp... | {"source_file": "replacing-merge-tree.md"} | [
-0.052205827087163925,
0.03965199738740921,
0.025487767532467842,
0.016856174916028976,
0.042832840234041214,
-0.14940595626831055,
-0.005339493043720722,
-0.017881445586681366,
0.039744310081005096,
0.02291051857173443,
0.04818999767303467,
0.10388172417879105,
0.00911235436797142,
-0.116... |
ef93b053-7588-4296-a8af-c36a35012df7 | During this process, the following occurs during part merging:
The row identified by the value 1 for column A has both an update row with version 2 and a delete row with version 3 (and a deleted column value of 1). The latest row, marked as deleted, is therefore retained.
The row identified by the value 2 for col... | {"source_file": "replacing-merge-tree.md"} | [
-0.0654817521572113,
0.02620331384241581,
-0.002052066847681999,
-0.042872071266174316,
0.02795260399580002,
-0.09413822740316391,
-0.03603648394346237,
-0.07669828087091446,
0.06256619095802307,
0.059584327042102814,
0.08571342378854752,
0.08151900768280029,
0.015152668580412865,
-0.05725... |
0eb7791d-08a9-489b-a98e-2d6960d908a2 | Users of ClickHouse will be familiar with choosing the columns in their tables
ORDER BY
clause to
optimize for query performance
. Generally, these columns should be selected based on your
frequent queries and listed in order of increasing cardinality
. Importantly, the ReplacingMergeTree imposes an additional cons... | {"source_file": "replacing-merge-tree.md"} | [
-0.031238513067364693,
0.006402413826435804,
-0.05216769501566887,
-0.06005037948489189,
-0.0377996601164341,
0.005713354330509901,
-0.020822172984480858,
-0.050445180386304855,
0.06230078637599945,
0.012840901501476765,
-0.03445201739668846,
0.11141417920589447,
-0.029435109347105026,
-0.... |
c918b1fe-6bf5-4234-a38d-25a874ccd1d1 | Querying ReplacingMergeTree {#querying-replacingmergetree}
At merge time, the ReplacingMergeTree identifies duplicate rows, using the values of the
ORDER BY
columns as a unique identifier, and either retains only the highest version or removes all duplicates if the latest version indicates a delete. This, however, ... | {"source_file": "replacing-merge-tree.md"} | [
-0.059936895966529846,
0.010578393004834652,
0.025958169251680374,
-0.03867710381746292,
-0.008242875337600708,
-0.05930695682764053,
-0.02382981777191162,
-0.07807037234306335,
0.0009583979262970388,
0.03710689768195152,
0.06040076166391373,
0.06136803701519966,
0.03536796569824219,
-0.12... |
918fec80-58ba-4ce9-8a50-a4ffd07d2b8c | In addition, we delete 1000 random posts by reinserting the rows but with a deleted column value of 1. Again, simulating this can be simulated with a simple
INSERT INTO SELECT
.
```sql
INSERT INTO posts_updateable SELECT
Version + 1 AS Version,
1 AS Deleted,
Id,
PostTypeId,
Ac... | {"source_file": "replacing-merge-tree.md"} | [
-0.02594512328505516,
-0.03400156646966934,
-0.0338057279586792,
0.02216886729001999,
-0.0246892049908638,
-0.08018981665372849,
0.06473035365343094,
-0.07794394344091415,
-0.0027477224357426167,
0.08560275286436081,
0.08091172575950623,
0.021910592913627625,
0.1334012895822525,
-0.0902719... |
1b7d07d1-1160-427f-98a3-b7d90de5f912 | Exploiting partitions with ReplacingMergeTree {#exploiting-partitions-with-replacingmergetree}
Merging of data in ClickHouse occurs at a partition level. When using ReplacingMergeTree, we recommend users partition their table according to best practices, provided users can ensure this
partitioning key does not chang... | {"source_file": "replacing-merge-tree.md"} | [
-0.036613814532756805,
-0.025604093447327614,
0.07196786999702454,
-0.0005009956657886505,
-0.005417706910520792,
-0.08106950670480728,
0.016566533595323563,
-0.013970299623906612,
0.006831466685980558,
-0.0313773937523365,
-0.01177193783223629,
0.04652980715036392,
-0.034254223108291626,
... |
4ad39e4f-58fc-4f04-92bc-bbe5e26e9cbd | // populate & update omitted
SELECT toYear(CreationDate) AS year, sum(AnswerCount) AS total_answers
FROM posts_with_part
FINAL
GROUP BY year
ORDER BY year ASC
ββyearββ¬βtotal_answersββ
β 2008 β 387832 β
β 2009 β 1165506 β
β 2010 β 1755437 β
...
β 2023 β 787032 β
β 2024 β 127765 β
βββ... | {"source_file": "replacing-merge-tree.md"} | [
-0.0731828436255455,
-0.02331741899251938,
0.07369954884052277,
0.03334850072860718,
0.039100244641304016,
-0.05122555047273636,
-0.044729866087436676,
0.02649977058172226,
0.0005006061983294785,
0.008293206803500652,
0.020202316343784332,
0.00970777589827776,
-0.021376309916377068,
-0.055... |
15c55c44-cd7a-49cc-94cf-4d7eec319188 | Partitioning and merging across partitions {#partitioning-and-merging-across-partitions}
As discussed in Exploiting Partitions with ReplacingMergeTree, we recommend partitioning tables as a best practice. Partitioning isolates data for more efficient merges and avoids merging across partitions, particularly during qu... | {"source_file": "replacing-merge-tree.md"} | [
-0.0062463609501719475,
0.01291852816939354,
0.051268767565488815,
-0.026663828641176224,
0.0042399512603878975,
-0.061560023576021194,
-0.009750339202582836,
0.04667875915765762,
-0.021855246275663376,
-0.025959881022572517,
0.03224143385887146,
0.023398635908961296,
-0.012993451207876205,
... |
0c3cad6d-b379-4ff6-ae1a-0b288144a2c2 | slug: /guides/developer/mutations
sidebar_label: 'Updating and deleting data'
sidebar_position: 1
keywords: ['UPDATE', 'DELETE', 'mutations']
title: 'Updating and deleting ClickHouse data'
description: 'Describes how to perform update and delete operations in ClickHouse'
show_related_blogs: false
doc_type: 'guide'
... | {"source_file": "mutations.md"} | [
-0.057571109384298325,
-0.02093178778886795,
-0.050581883639097214,
0.01798774115741253,
-0.004350977949798107,
-0.07107648253440857,
0.02068960852921009,
-0.06954406201839447,
-0.02983159013092518,
0.0564797967672348,
0.10305273532867432,
0.04030295088887215,
0.10109582543373108,
-0.11484... |
8146f49b-2fc7-48ad-a25f-f2c2f38d8a7b | :::note
To delete all of the data in a table, it is more efficient to use the command
TRUNCATE TABLE [<database].]<table>
command. This command can also be executed
ON CLUSTER
.
:::
View the
DELETE
statement
docs page for more details.
Lightweight deletes {#lightweight-deletes}
Another option for deleting ... | {"source_file": "mutations.md"} | [
0.04808153584599495,
-0.006846810225397348,
-0.01094068307429552,
0.06492727249860764,
0.01510726660490036,
-0.05492676421999931,
0.04879993945360184,
-0.06906653195619583,
0.04102916643023491,
0.05022177845239639,
0.0850309208035469,
0.04424113407731056,
0.057910554111003876,
-0.097683168... |
42ea04cf-f162-496d-9ef3-db07e3738663 | slug: /guides/developer/merge-table-function
sidebar_label: 'Merge table function'
title: 'Merge table function'
description: 'Query multiple tables at the same time.'
doc_type: 'reference'
keywords: ['merge', 'table function', 'query patterns', 'table engine', 'data access']
The
merge table function
lets us quer... | {"source_file": "merge-table-function.md"} | [
-0.008229264989495277,
0.002081054262816906,
-0.012078063562512398,
-0.01778317429125309,
-0.02024788409471512,
0.022854100912809372,
-0.027949213981628418,
0.022948535159230232,
-0.04521460458636284,
0.06478526443243027,
0.06030622497200966,
-0.06583873927593231,
0.06135433539748192,
-0.0... |
23335893-2b14-4e20-8bdc-5e62763b9616 | Schema of multiple tables {#schema-multiple-tables}
We can run the following query to list the columns in each table along with their types side by side, so that it's easier to see the differences.
sql
SELECT * EXCEPT(position) FROM (
SELECT position, name,
any(if(table = 'atp_matches_1960s', type, null)... | {"source_file": "merge-table-function.md"} | [
0.09422039240598679,
0.019985396414995193,
0.026187898591160774,
-0.00909513235092163,
0.03910880908370018,
0.056539636105298996,
-0.007032863795757294,
0.017560094594955444,
-0.10513465851545334,
0.04472033306956291,
-0.00015324870764743537,
-0.04829968512058258,
0.03716357424855232,
0.01... |
881ff44a-7a18-4c0a-8848-7d1b7d7dbe0c | sql
SELECT loser_name, score
FROM merge('atp_matches*')
WHERE winner_name = 'John McEnroe'
AND loser_seed = 1;
text
ββloser_nameβββββ¬βscoreββββββββββββββββββββββββββββ
β Bjorn Borg β ['6-3','6-4'] β
β Bjorn Borg β ['7-6','6-1','6-7','5-7','6-4'] β
β Bjorn Borg β ['7-6','6-4'] ... | {"source_file": "merge-table-function.md"} | [
-0.006644821725785732,
0.00776333874091506,
0.015569214709103107,
0.016676029190421104,
-0.02692226506769657,
0.04625977203249931,
0.05084550380706787,
0.06154782697558403,
0.02420172467827797,
0.035672735422849655,
-0.027284612879157066,
-0.025040846318006516,
0.02172044664621353,
-0.0148... |
6f789f8e-9605-42c8-b555-6a355203898a | We could also use this virtual column as part of a query to count the values for the
walkover
column:
sql
SELECT _table, walkover, count()
FROM merge('atp_matches*')
GROUP BY ALL
ORDER BY _table;
text
ββ_tableβββββββββββββ¬βwalkoverββ¬βcount()ββ
β atp_matches_1960s β α΄Ία΅α΄Έα΄Έ β 7542 β
β atp_matches_1970s β α΄Ία΅α΄Έα΄Έ ... | {"source_file": "merge-table-function.md"} | [
0.08888175338506699,
0.0017870457377284765,
0.018292302265763283,
-0.013337800279259682,
-0.031293388456106186,
0.13235488533973694,
0.0012914767721667886,
0.03925654664635658,
0.0011952916393056512,
0.00077183882240206,
0.03454083204269409,
-0.08755030483007431,
0.034968301653862,
-0.0342... |
edcc0f97-7b89-47c5-b030-e9c95ef7e481 | slug: /guides/developer/understanding-query-execution-with-the-analyzer
sidebar_label: 'Understanding query execution with the analyzer'
title: 'Understanding Query Execution with the Analyzer'
description: 'Describes how you can use the analyzer to understand how ClickHouse executes your queries'
doc_type: 'guide'
key... | {"source_file": "understanding-query-execution-with-the-analyzer.md"} | [
-0.009532653726637363,
0.04263963922858238,
-0.05766606330871582,
0.041962966322898865,
0.05204975977540016,
-0.11144597828388214,
0.012528144754469395,
0.0065943216904997826,
-0.03367120772600174,
-0.007056740578263998,
0.012441691011190414,
0.0012241463409736753,
0.07836990058422089,
0.0... |
b4bcea51-7cf3-4ce6-9d8f-393be0fa08ec | ```sql
EXPLAIN AST SELECT min(timestamp), max(timestamp) FROM session_events;
ββexplainβββββββββββββββββββββββββββββββββββββββββββββ
β SelectWithUnionQuery (children 1) β
β ExpressionList (children 1) β
β SelectQuery (children 2) β
β ExpressionList ... | {"source_file": "understanding-query-execution-with-the-analyzer.md"} | [
-0.04888323321938515,
0.058438438922166824,
0.003680863883346319,
0.0710677057504654,
0.010084566660225391,
-0.018108071759343147,
0.07703717797994614,
0.09274700284004211,
0.049165673553943634,
0.05276006832718849,
-0.03464123606681824,
-0.05194380506873131,
0.013606728054583073,
-0.00954... |
80f3f40b-19d1-4418-b655-f1f5097456a3 | ```sql
EXPLAIN QUERY TREE passes=0 SELECT min(timestamp) AS minimum_date, max(timestamp) AS maximum_date FROM session_events SETTINGS allow_experimental_analyzer=1;
ββexplainβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β QUERY id: 0 ... | {"source_file": "understanding-query-execution-with-the-analyzer.md"} | [
0.03263073414564133,
0.04791989177465439,
0.011613833718001842,
0.04719625040888786,
-0.014636451378464699,
-0.05912734195590019,
0.019763292744755745,
0.08114239573478699,
-0.02075061947107315,
0.07914123684167862,
-0.04633687809109688,
-0.07935410737991333,
0.037326715886592865,
0.008166... |
a1283d5c-2eb6-4cd4-a3a8-92c6c96d57f0 | ```sql
EXPLAIN QUERY TREE passes=20 SELECT min(timestamp) AS minimum_date, max(timestamp) AS maximum_date FROM session_events SETTINGS allow_experimental_analyzer=1;
ββexplainββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β QUERY id: 0 ... | {"source_file": "understanding-query-execution-with-the-analyzer.md"} | [
0.03934570401906967,
0.03973193094134331,
0.03322017565369606,
0.08032799512147903,
0.0057231648825109005,
-0.062173403799533844,
0.009913465939462185,
0.05555342510342598,
0.0006058558938093483,
0.08890178054571152,
-0.02864518202841282,
-0.0864831954240799,
0.03437207266688347,
-0.033323... |
227c274f-897d-4d86-a82c-36f0f59e7d81 | Even though this is giving us some information, we can get more. For example, maybe we want to know the column's name on top of which we need the projections. You can add the header to the query:
```SQL
EXPLAIN header = 1
WITH (
SELECT count(
)
FROM session_events
) AS total_rows
SELECT
type,
m... | {"source_file": "understanding-query-execution-with-the-analyzer.md"} | [
0.041145455092191696,
0.03625497967004776,
-0.05224035307765007,
0.06935629993677139,
-0.02994168922305107,
0.0031362809240818024,
0.08022468537092209,
0.05574652552604675,
-0.00017083578859455884,
0.0945664793252945,
-0.028526591137051582,
-0.11887921392917633,
-0.006682052742689848,
0.00... |
3b2339a9-4ae4-4d07-a7dd-e66c002c679b | ββexplainβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Expression ((Projection + Before ORDER BY)) β
β Actions: INPUT :: 0 -> type Stri... | {"source_file": "understanding-query-execution-with-the-analyzer.md"} | [
-0.04661060497164726,
0.024151695892214775,
-0.023066340014338493,
-0.036344416439533234,
-0.041733432561159134,
0.019292881712317467,
-0.03929596021771431,
0.010064985603094101,
-0.027851013466715813,
0.08678962290287018,
0.04132179915904999,
-0.027611244469881058,
0.028966857120394707,
0... |
c00ed2bd-92d1-4c77-b6c5-07449e27eed9 | β Arguments: timestamp β
β max(timestamp) β
β Function: max(DateTime) ... | {"source_file": "understanding-query-execution-with-the-analyzer.md"} | [
0.02447683736681938,
0.0220627598464489,
-0.011976934038102627,
0.016957968473434448,
-0.0460345558822155,
0.03434940427541733,
0.0652879923582077,
0.02390519715845585,
0.040390655398368835,
0.02204812318086624,
0.049782514572143555,
-0.033103637397289276,
-0.0046623460948467255,
0.0354830... |
f4b3b213-5ac6-44c3-8107-df6ddd638aa2 | You can now see all the inputs, functions, aliases, and data types that are being used. You can see some of the optimizations that the planner is going to apply
here
.
Query pipeline {#query-pipeline}
A query pipeline is generated from the query plan. The query pipeline is very similar to the query plan, with the ... | {"source_file": "understanding-query-execution-with-the-analyzer.md"} | [
-0.008101974613964558,
0.004822948481887579,
0.020076675340533257,
0.06062491610646248,
-0.040694091469049454,
-0.0730297714471817,
-0.037550557404756546,
0.032943155616521835,
0.02673879824578762,
0.034194767475128174,
-0.11969088762998581,
-0.024195507168769836,
-0.056476421654224396,
-0... |
8f56cc3c-f0ff-48ae-81b8-bba9cd6f3bc8 | response
digraph
{
rankdir="LR";
{ node [shape = rect]
subgraph cluster_0 {
label ="Expression";
style=filled;
color=lightgrey;
node [style=filled,color=white];
{ rank = same;
n5 [label="ExpressionTransform Γ 2"];
}
}
subgraph cluster_1 {
label ="Aggregating";
s... | {"source_file": "understanding-query-execution-with-the-analyzer.md"} | [
-0.02784847840666771,
-0.0057814461179077625,
0.022559380158782005,
0.023694230243563652,
-0.015628207474946976,
0.03608055040240288,
-0.03833100572228432,
0.006554304156452417,
-0.057869430631399155,
-0.04466334357857704,
-0.03610633686184883,
-0.07609924674034119,
0.013174710795283318,
-... |
14c6b6bd-c94e-40f1-8c80-49e54d67b9e1 | response
digraph
{
rankdir="LR";
{ node [shape = rect]
n0[label="MergeTreeSelect(pool: PrefetchedReadPool, algorithm: Thread)"];
n1[label="MergeTreeSelect(pool: PrefetchedReadPool, algorithm: Thread)"];
n2[label="ExpressionTransform"];
n3[label="ExpressionTransform"];
n4[label="StrictResize"];
... | {"source_file": "understanding-query-execution-with-the-analyzer.md"} | [
-0.04104876518249512,
-0.005507919937372208,
0.0018453469965606928,
-0.017593665048480034,
-0.0905817523598671,
0.019545039162039757,
-0.0514754056930542,
0.05410536006093025,
-0.07145056873559952,
-0.035207368433475494,
-0.04027164727449417,
-0.037271250039339066,
-0.029127588495612144,
-... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.