Skip to content

Instantly share code, notes, and snippets.

@tom-clickhouse
Created December 27, 2023 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tom-clickhouse/2362a0279f2159cc162e0105bc745952 to your computer and use it in GitHub Desktop.
Save tom-clickhouse/2362a0279f2159cc162e0105bc745952 to your computer and use it in GitHub Desktop.
Table with partitioning key
CREATE TABLE default.upclick_metrics
(
`target` String,
`status_code` UInt8,
`latency` UInt16,
`continent_code` String,
`country_iso_code` String,
`country_name_en` String,
`city_name_en` String,
`latitude` Float64,
`longitude` Float64,
`receive_timestamp` DateTime64 MATERIALIZED now64()
)
ENGINE = ReplicatedMergeTree
PARTITION BY continent_code
ORDER BY (target, status_code, continent_code, country_iso_code, country_name_en, city_name_en)
SETTINGS old_parts_lifetime = 86400; -- for getting the part names from system.parts table for a bit longer than 8 minutes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment