From 8996a04965096f0715fc6658709ba693819dd9cc Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Wed, 9 Feb 2022 19:12:21 +0100 Subject: [PATCH] feat(db): create new indexes --- ee/scripts/helm/db/init_dbs/postgresql/1.5.0/1.5.0.sql | 1 + ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql | 1 + scripts/helm/db/init_dbs/postgresql/1.5.0/1.5.0.sql | 2 ++ scripts/helm/db/init_dbs/postgresql/init_schema.sql | 1 + 4 files changed, 5 insertions(+) diff --git a/ee/scripts/helm/db/init_dbs/postgresql/1.5.0/1.5.0.sql b/ee/scripts/helm/db/init_dbs/postgresql/1.5.0/1.5.0.sql index 2ccc60080..b509d2d23 100644 --- a/ee/scripts/helm/db/init_dbs/postgresql/1.5.0/1.5.0.sql +++ b/ee/scripts/helm/db/init_dbs/postgresql/1.5.0/1.5.0.sql @@ -8,5 +8,6 @@ $$ LANGUAGE sql IMMUTABLE; ALTER TABLE public.metrics ADD COLUMN IF NOT EXISTS active boolean NOT NULL DEFAULT TRUE; +CREATE INDEX IF NOT EXISTS resources_timestamp_duration_durationgt0NN_idx ON events.resources (timestamp, duration) WHERE duration > 0 AND duration IS NOT NULL; COMMIT; ALTER TYPE public.error_source ADD VALUE IF NOT EXISTS 'elasticsearch'; -- cannot add new value inside a transaction block \ No newline at end of file diff --git a/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql b/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql index 3519e4852..ffa83689c 100644 --- a/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql +++ b/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql @@ -1061,6 +1061,7 @@ $$ CREATE INDEX IF NOT EXISTS resources_session_id_timestamp_url_host_firstparty_idx ON events.resources (session_id, timestamp, url_host) WHERE type IN ('fetch', 'script'); CREATE INDEX IF NOT EXISTS resources_session_id_timestamp_duration_durationgt0NN_img_idx ON events.resources (session_id, timestamp, duration) WHERE duration > 0 AND duration IS NOT NULL AND type = 'img'; CREATE INDEX IF NOT EXISTS resources_timestamp_session_id_idx ON events.resources (timestamp, session_id); + CREATE INDEX IF NOT EXISTS resources_timestamp_duration_durationgt0NN_idx ON events.resources (timestamp, duration) WHERE duration > 0 AND duration IS NOT NULL; CREATE TABLE IF NOT EXISTS events.performance ( diff --git a/scripts/helm/db/init_dbs/postgresql/1.5.0/1.5.0.sql b/scripts/helm/db/init_dbs/postgresql/1.5.0/1.5.0.sql index cd386f5ab..180b02d58 100644 --- a/scripts/helm/db/init_dbs/postgresql/1.5.0/1.5.0.sql +++ b/scripts/helm/db/init_dbs/postgresql/1.5.0/1.5.0.sql @@ -8,5 +8,7 @@ $$ LANGUAGE sql IMMUTABLE; ALTER TABLE public.metrics ADD COLUMN IF NOT EXISTS active boolean NOT NULL DEFAULT TRUE; + +CREATE INDEX IF NOT EXISTS resources_timestamp_duration_durationgt0NN_idx ON events.resources (timestamp, duration) WHERE duration > 0 AND duration IS NOT NULL; COMMIT; ALTER TYPE public.error_source ADD VALUE IF NOT EXISTS 'elasticsearch'; -- cannot add new value inside a transaction block \ No newline at end of file diff --git a/scripts/helm/db/init_dbs/postgresql/init_schema.sql b/scripts/helm/db/init_dbs/postgresql/init_schema.sql index 06fe88688..abf4df15a 100644 --- a/scripts/helm/db/init_dbs/postgresql/init_schema.sql +++ b/scripts/helm/db/init_dbs/postgresql/init_schema.sql @@ -839,6 +839,7 @@ $$ CREATE INDEX resources_session_id_timestamp_url_host_firstparty_idx ON events.resources (session_id, timestamp, url_host) WHERE type IN ('fetch', 'script'); CREATE INDEX resources_session_id_timestamp_duration_durationgt0NN_img_idx ON events.resources (session_id, timestamp, duration) WHERE duration > 0 AND duration IS NOT NULL AND type = 'img'; CREATE INDEX resources_timestamp_session_id_idx ON events.resources (timestamp, session_id); + CREATE INDEX resources_timestamp_duration_durationgt0NN_idx ON events.resources (timestamp, duration) WHERE duration > 0 AND duration IS NOT NULL; CREATE TABLE events.performance (