Merge pull request #8402 from thingsboard/feature/alarm-tenant-id-active-idx
Feature/alarm tenant id active idx
This commit is contained in:
commit
cfd9732c32
@ -47,11 +47,15 @@ UPDATE alarm SET acknowledged = true, cleared = false WHERE status = 'ACTIVE_ACK
|
||||
UPDATE alarm SET acknowledged = false, cleared = true WHERE status = 'CLEARED_UNACK';
|
||||
UPDATE alarm SET acknowledged = false, cleared = false WHERE status = 'ACTIVE_UNACK';
|
||||
|
||||
-- Drop index by 'status' column and replace with new one that has only active alarms;
|
||||
-- Drop index by 'status' column and replace with new indexes that has only active alarms;
|
||||
DROP INDEX IF EXISTS idx_alarm_originator_alarm_type_active;
|
||||
CREATE INDEX IF NOT EXISTS idx_alarm_originator_alarm_type_active
|
||||
ON alarm USING btree (originator_id, type) WHERE cleared = false;
|
||||
|
||||
DROP INDEX IF EXISTS idx_alarm_tenant_alarm_type_active;
|
||||
CREATE INDEX IF NOT EXISTS idx_alarm_tenant_alarm_type_active
|
||||
ON alarm USING btree (tenant_id, type) WHERE cleared = false;
|
||||
|
||||
-- Cover index by alarm type to optimize propagated alarm queries;
|
||||
DROP INDEX IF EXISTS idx_entity_alarm_entity_id_alarm_type_created_time_alarm_id;
|
||||
CREATE INDEX IF NOT EXISTS idx_entity_alarm_entity_id_alarm_type_created_time_alarm_id ON entity_alarm
|
||||
|
||||
@ -20,10 +20,13 @@ CREATE INDEX IF NOT EXISTS idx_alarm_originator_created_time ON alarm(originator
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_alarm_tenant_created_time ON alarm(tenant_id, created_time DESC);
|
||||
|
||||
-- Drop index by 'status' column and replace with new one that has only active alarms;
|
||||
-- Drop index by 'status' column and replace with new indexes that has only active alarms;
|
||||
CREATE INDEX IF NOT EXISTS idx_alarm_originator_alarm_type_active
|
||||
ON alarm USING btree (originator_id, type) WHERE cleared = false;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_alarm_tenant_alarm_type_active
|
||||
ON alarm USING btree (tenant_id, type) WHERE cleared = false;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_alarm_tenant_alarm_type_created_time ON alarm(tenant_id, type, created_time DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_alarm_tenant_assignee_created_time ON alarm(tenant_id, assignee_id, created_time DESC);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user