samples.sql
1 CREATE TABLE samples ( 2 time TIMESTAMPTZ NOT NULL, 3 event_name TEXT NOT NULL, 4 source TEXT NOT NULL, 5 type TEXT NOT NULL, 6 metric_id UUID NOT NULL REFERENCES metrics(id), 7 instance_index INT NOT NULL DEFAULT 0, 8 value DOUBLE PRECISION NOT NULL, 9 PRIMARY KEY (time, event_name, metric_id, instance_index) 10 ); 11 12 SELECT create_hypertable('samples', 'time', if_not_exists => TRUE); 13 14 CREATE INDEX samples_source_type_metric_time_idx 15 ON samples (source, type, metric_id, time DESC);