Commit 6ddf0a63984ff60705fc3a4c6fd02b71d668181b

Authored by Andrew Shvayka
1 parent 9ce9e004

Alarm Indexes improved

@@ -75,7 +75,8 @@ CREATE OR REPLACE PROCEDURE drop_all_idx() @@ -75,7 +75,8 @@ CREATE OR REPLACE PROCEDURE drop_all_idx()
75 $$ 75 $$
76 BEGIN 76 BEGIN
77 DROP INDEX IF EXISTS idx_alarm_originator_alarm_type; 77 DROP INDEX IF EXISTS idx_alarm_originator_alarm_type;
78 - DROP INDEX IF EXISTS idx_alarm_originator_alarm_time; 78 + DROP INDEX IF EXISTS idx_alarm_originator_created_time;
  79 + DROP INDEX IF EXISTS idx_alarm_tenant_created_time;
79 DROP INDEX IF EXISTS idx_event_type_entity_id; 80 DROP INDEX IF EXISTS idx_event_type_entity_id;
80 DROP INDEX IF EXISTS idx_relation_to_id; 81 DROP INDEX IF EXISTS idx_relation_to_id;
81 DROP INDEX IF EXISTS idx_relation_from_id; 82 DROP INDEX IF EXISTS idx_relation_from_id;
@@ -93,7 +94,8 @@ CREATE OR REPLACE PROCEDURE create_all_idx() @@ -93,7 +94,8 @@ CREATE OR REPLACE PROCEDURE create_all_idx()
93 $$ 94 $$
94 BEGIN 95 BEGIN
95 CREATE INDEX IF NOT EXISTS idx_alarm_originator_alarm_type ON alarm(originator_id, type, start_ts DESC); 96 CREATE INDEX IF NOT EXISTS idx_alarm_originator_alarm_type ON alarm(originator_id, type, start_ts DESC);
96 - CREATE INDEX IF NOT EXISTS idx_alarm_originator_alarm_time ON alarm(originator_id, created_time DESC); 97 + CREATE INDEX IF NOT EXISTS idx_alarm_originator_created_time ON alarm(originator_id, created_time DESC);
  98 + CREATE INDEX IF NOT EXISTS idx_alarm_tenant_created_time ON alarm(tenant_id, created_time DESC);
97 CREATE INDEX IF NOT EXISTS idx_event_type_entity_id ON event(tenant_id, event_type, entity_type, entity_id); 99 CREATE INDEX IF NOT EXISTS idx_event_type_entity_id ON event(tenant_id, event_type, entity_type, entity_id);
98 CREATE INDEX IF NOT EXISTS idx_relation_to_id ON relation(relation_type_group, to_type, to_id); 100 CREATE INDEX IF NOT EXISTS idx_relation_to_id ON relation(relation_type_group, to_type, to_id);
99 CREATE INDEX IF NOT EXISTS idx_relation_from_id ON relation(relation_type_group, from_type, from_id); 101 CREATE INDEX IF NOT EXISTS idx_relation_from_id ON relation(relation_type_group, from_type, from_id);
@@ -16,7 +16,9 @@ @@ -16,7 +16,9 @@
16 16
17 CREATE INDEX IF NOT EXISTS idx_alarm_originator_alarm_type ON alarm(originator_id, type, start_ts DESC); 17 CREATE INDEX IF NOT EXISTS idx_alarm_originator_alarm_type ON alarm(originator_id, type, start_ts DESC);
18 18
19 -CREATE INDEX IF NOT EXISTS idx_alarm_originator_alarm_time ON alarm(originator_id, created_time DESC); 19 +CREATE INDEX IF NOT EXISTS idx_alarm_originator_created_time ON alarm(originator_id, created_time DESC);
  20 +
  21 +CREATE INDEX IF NOT EXISTS idx_alarm_tenant_created_time ON alarm(tenant_id, created_time DESC);
20 22
21 CREATE INDEX IF NOT EXISTS idx_event_type_entity_id ON event(tenant_id, event_type, entity_type, entity_id); 23 CREATE INDEX IF NOT EXISTS idx_event_type_entity_id ON event(tenant_id, event_type, entity_type, entity_id);
22 24