mirror of
https://github.com/plausible/analytics.git
synced 2024-12-26 02:55:02 +03:00
8ba2b934b3
* Add data migration for moving to VersionedCollapsingMergeTree This has been tested locally and partially on staging. Still requires a bit of work to verify. Verification query: ``` SELECT main._partition_id, tmp.count, main.count FROM ( SELECT _partition_id, count() AS count FROM sessions_v2_tmp_versioned GROUP BY _partition_id ) AS tmp FULL OUTER JOIN ( SELECT _partition_id, count() AS count FROM sessions_v2 GROUP BY _partition_id ) AS main ON (tmp._partition_id == main._partition_id) ORDER BY main._partition_id ``` * Add an early exit to migration * cluster? extract common code
14 lines
551 B
Elixir
14 lines
551 B
Elixir
CREATE TABLE sessions_v2_tmp_versioned
|
|
<%= if @cluster? do %>ON CLUSTER '{cluster}'<% end %>
|
|
AS sessions_v2
|
|
<%= if @cluster? do %>
|
|
ENGINE = ReplicatedVersionedCollapsingMergeTree('/clickhouse/{cluster}/tables/{shard}/plausible_prod/sessions_v2_<%= @unique_suffix %>', '{replica}', sign, events)
|
|
<% else %>
|
|
ENGINE = VersionedCollapsingMergeTree(sign, events)
|
|
<% end %>
|
|
PARTITION BY toYYYYMM(start)
|
|
PRIMARY KEY (site_id, toDate(start), user_id, session_id)
|
|
ORDER BY (site_id, toDate(start), user_id, session_id)
|
|
SAMPLE BY user_id
|
|
<%= @table_settings %>
|