-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add visitor id to custom events and pageviews
- Loading branch information
Showing
26 changed files
with
993 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
1 change: 1 addition & 0 deletions
1
pkg/embedded/ch_migrations/20240417104420_add_pageviews_visitor_id.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE prisme.events_pageviews ADD COLUMN visitor_id String DEFAULT 'prisme_00'; |
Empty file.
28 changes: 28 additions & 0 deletions
28
pkg/embedded/ch_migrations/20240417104421_BREAK_recreate_events_pageviews_table.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
RENAME TABLE events_pageviews TO events_pageviews_old; | ||
|
||
-- Add visitor_id to primary key so it can be used for sampling. | ||
|
||
-- It is beneficial for queries to order the primary key columns by cardinality in ascending order. | ||
-- https://clickhouse.com/docs/en/optimize/sparse-primary-indexes#summary | ||
CREATE TABLE events_pageviews ( | ||
timestamp DateTime('UTC'), | ||
domain String, | ||
path String, | ||
operating_system LowCardinality(String), | ||
browser_family LowCardinality(String), | ||
device LowCardinality(String), | ||
referrer_domain String, | ||
country_code LowCardinality(String), | ||
visitor_id String | ||
) | ||
ENGINE = MergeTree | ||
PRIMARY KEY (domain, path, toDate(timestamp), xxh3(visitor_id)) | ||
ORDER BY (domain, path, toDate(timestamp), xxh3(visitor_id), operating_system, browser_family, device, referrer_domain, country_code) | ||
SAMPLE BY xxh3(visitor_id) | ||
PARTITION BY toYYYYMM(timestamp); | ||
|
||
-- Move rows to new table. | ||
INSERT INTO events_pageviews SELECT * FROM events_pageviews_old; | ||
|
||
-- Delete old table. | ||
DROP TABLE events_pageviews_old; |
Empty file.
Oops, something went wrong.