Commit f60137de34a3424be147c2f78ec57dbcee440fb9
1 parent
1037e5d2
events: schema_update_event fixed typo with a comment. schema-entities-idx updat…
…ed. Upgrade order fixed based on review comments.
Showing
3 changed files
with
19 additions
and
4 deletions
... | ... | @@ -76,7 +76,7 @@ COMMENT ON INDEX public.idx_event_ts |
76 | 76 | |
77 | 77 | DROP INDEX IF EXISTS public.idx_event_tenant_entity_type_entity_event_type_created_time_des; |
78 | 78 | |
79 | -CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_event_tenant_entity_type_entity_event_type_created_time_des | |
79 | +-- CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_event_tenant_entity_type_entity_event_type_created_time_des | |
80 | 80 | CREATE INDEX IF NOT EXISTS idx_event_tenant_entity_type_entity_event_type_created_time_des |
81 | 81 | ON public.event USING btree |
82 | 82 | (tenant_id ASC NULLS LAST, entity_type ASC NULLS LAST, entity_id ASC NULLS LAST, event_type ASC NULLS LAST, created_time DESC NULLS LAST) | ... | ... |
... | ... | @@ -459,10 +459,11 @@ public class SqlDatabaseUpgradeService implements DatabaseEntitiesUpgradeService |
459 | 459 | schemaUpdateFile = Paths.get(installScripts.getDataDir(), "upgrade", "3.2.2", "schema_update_ttl.sql"); |
460 | 460 | loadSql(schemaUpdateFile, conn); |
461 | 461 | log.info("Edge TTL functions successfully loaded!"); |
462 | - conn.createStatement().execute("UPDATE tb_schema_settings SET schema_version = 3003000;"); | |
463 | 462 | log.info("Updating indexes and TTL procedure for event table..."); |
464 | 463 | schemaUpdateFile = Paths.get(installScripts.getDataDir(), "upgrade", "3.2.2", "schema_update_event.sql"); |
465 | 464 | loadSql(schemaUpdateFile, conn); |
465 | + log.info("Updating schema settings..."); | |
466 | + conn.createStatement().execute("UPDATE tb_schema_settings SET schema_version = 3003000;"); | |
466 | 467 | log.info("Schema updated."); |
467 | 468 | } catch (Exception e) { |
468 | 469 | log.error("Failed updating schema!!!", e); | ... | ... |
... | ... | @@ -22,8 +22,6 @@ CREATE INDEX IF NOT EXISTS idx_alarm_tenant_created_time ON alarm(tenant_id, cre |
22 | 22 | |
23 | 23 | CREATE INDEX IF NOT EXISTS idx_alarm_tenant_alarm_type_created_time ON alarm(tenant_id, type, created_time DESC); |
24 | 24 | |
25 | -CREATE INDEX IF NOT EXISTS idx_event_type_entity_id ON event(tenant_id, event_type, entity_type, entity_id); | |
26 | - | |
27 | 25 | CREATE INDEX IF NOT EXISTS idx_relation_to_id ON relation(relation_type_group, to_type, to_id); |
28 | 26 | |
29 | 27 | CREATE INDEX IF NOT EXISTS idx_relation_from_id ON relation(relation_type_group, from_type, from_id); |
... | ... | @@ -47,3 +45,19 @@ CREATE INDEX IF NOT EXISTS idx_attribute_kv_by_key_and_last_update_ts ON attribu |
47 | 45 | CREATE INDEX IF NOT EXISTS idx_audit_log_tenant_id_and_created_time ON audit_log(tenant_id, created_time); |
48 | 46 | |
49 | 47 | CREATE INDEX IF NOT EXISTS idx_rpc_tenant_id_device_id ON rpc(tenant_id, device_id); |
48 | + | |
49 | +CREATE INDEX IF NOT EXISTS idx_event_ts | |
50 | + ON public.event USING btree | |
51 | + (ts DESC NULLS LAST) | |
52 | + WITH (FILLFACTOR=95); | |
53 | + | |
54 | +COMMENT ON INDEX public.idx_event_ts | |
55 | + IS 'This index helps to delete events by TTL using timestamp'; | |
56 | + | |
57 | +CREATE INDEX IF NOT EXISTS idx_event_tenant_entity_type_entity_event_type_created_time_des | |
58 | + ON public.event USING btree | |
59 | + (tenant_id ASC NULLS LAST, entity_type ASC NULLS LAST, entity_id ASC NULLS LAST, event_type ASC NULLS LAST, created_time DESC NULLS LAST) | |
60 | + WITH (FILLFACTOR=95); | |
61 | + | |
62 | +COMMENT ON INDEX public.idx_event_tenant_entity_type_entity_event_type_created_time_des | |
63 | + IS 'This index helps to open latest events on UI fast'; | |
\ No newline at end of file | ... | ... |