From 7dd9a491b9ecacfe34ee804f23a0830157be94b9 Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Thu, 1 Dec 2022 12:38:41 +0200 Subject: [PATCH] Add id indexes on new partitioned tables --- application/src/main/data/upgrade/3.4.1/schema_update.sql | 1 + dao/src/main/resources/sql/schema-entities-idx.sql | 2 ++ 2 files changed, 3 insertions(+) diff --git a/application/src/main/data/upgrade/3.4.1/schema_update.sql b/application/src/main/data/upgrade/3.4.1/schema_update.sql index 888ff246fe..a3d7bfb78f 100644 --- a/application/src/main/data/upgrade/3.4.1/schema_update.sql +++ b/application/src/main/data/upgrade/3.4.1/schema_update.sql @@ -112,6 +112,7 @@ CREATE TABLE IF NOT EXISTS edge_event ( ts bigint NOT NULL ) PARTITION BY RANGE (created_time); CREATE INDEX IF NOT EXISTS idx_edge_event_tenant_id_and_created_time ON edge_event(tenant_id, created_time DESC); +CREATE INDEX IF NOT EXISTS idx_edge_event_id ON edge_event(id); CREATE OR REPLACE PROCEDURE migrate_edge_event(IN start_time_ms BIGINT, IN end_time_ms BIGINT, IN partition_size_ms BIGINT) LANGUAGE plpgsql AS diff --git a/dao/src/main/resources/sql/schema-entities-idx.sql b/dao/src/main/resources/sql/schema-entities-idx.sql index f60fe3d39f..e4c766e81d 100644 --- a/dao/src/main/resources/sql/schema-entities-idx.sql +++ b/dao/src/main/resources/sql/schema-entities-idx.sql @@ -54,6 +54,8 @@ CREATE INDEX IF NOT EXISTS idx_audit_log_id ON audit_log(id); CREATE INDEX IF NOT EXISTS idx_edge_event_tenant_id_and_created_time ON edge_event(tenant_id, created_time DESC); +CREATE INDEX IF NOT EXISTS idx_edge_event_id ON edge_event(id); + CREATE INDEX IF NOT EXISTS idx_rpc_tenant_id_device_id ON rpc(tenant_id, device_id); CREATE INDEX IF NOT EXISTS idx_device_external_id ON device(tenant_id, external_id);