-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathschema-2.sql
More file actions
27 lines (26 loc) · 829 Bytes
/
schema-2.sql
File metadata and controls
27 lines (26 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
CREATE TABLE rollup_events_5min (
customer_id bigint,
event_type text,
country text,
browser text,
minute timestamptz,
event_count bigint,
device_distinct_count hll,
session_distinct_count hll,
top_devices_1000 jsonb
);
CREATE UNIQUE INDEX rollup_events_5min_unique_idx ON rollup_events_5min(customer_id,event_type,country,browser,minute);
SELECT create_distributed_table('rollup_events_5min','customer_id');
CREATE TABLE rollup_events_1hr (
customer_id bigint,
event_type text,
country text,
browser text,
hour timestamptz,
event_count bigint,
device_distinct_count hll,
session_distinct_count hll,
top_devices_1000 jsonb
);
CREATE UNIQUE INDEX rollup_events_1hr_unique_idx ON rollup_events_1hr(customer_id,event_type,country,browser,hour);
SELECT create_distributed_table('rollup_events_1hr','customer_id');