diff --git a/UPGRADE.md b/UPGRADE.md index b77e4c4b..bd68adb1 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -2,6 +2,32 @@ Upgrade documentation for Zeebe Simple Monitor ================================================== +## Upgrading from v2.1.0 + +In order to improve database lookup performance, a handful of indices was added to the database structure. +Zeebe Simple Monitor will not alter existing database tables automatically, but if you have a PostgreSQL +or other DB running, you may want to alter the table structures manually, in order to improve lookup performance. +Again, this is an optional step - Zeebe Simple Monitor will work as is without it - just a bit slower response times. + +Of course, if you use an in-memory DB or do not need to keep prior data, then simply drop all tables and sequences, +and let Zeebe Simple Monitor create them again for you (automatic creation works). + +### Upgrade procedure + +1. stop Zeebe Simple Monitor (v2.1.0) +2. run the SQL script below against your PostgreSQL Database +3. start up Zeebe Simple Monitor (new version) + +```sql +CREATE INDEX error_processInstanceKeyIndex ON error (process_instance_key_); +CREATE INDEX incident_processInstanceKeyIndex ON incident (process_instance_key_); +CREATE INDEX job_processInstanceKeyIndex ON job (process_instance_key_); +CREATE INDEX message_subscription_processInstanceKeyIndex ON message_subscription (process_instance_key_); +CREATE INDEX timer_processInstanceKeyIndex ON timer (process_instance_key_); +``` +(This SQL was developed and tested using a recent PostgreSQL instance. +You might need to adopt that if you're using another Database) + ## Upgrading from v2.0.0 Due to some issues with storing variables and element instances, the database structure changed. diff --git a/src/main/java/io/zeebe/monitor/entity/ElementInstanceEntity.java b/src/main/java/io/zeebe/monitor/entity/ElementInstanceEntity.java index 2bcd8857..49f5279f 100644 --- a/src/main/java/io/zeebe/monitor/entity/ElementInstanceEntity.java +++ b/src/main/java/io/zeebe/monitor/entity/ElementInstanceEntity.java @@ -19,7 +19,8 @@ @Entity(name = "ELEMENT_INSTANCE") @Table(indexes = { - // performance reason, because we use it in the ElementInstanceRepository.findByProcessInstanceKey() + // performance reason, because we use it in the + // {@link io.zeebe.monitor.repository.ElementInstanceRepository#findByProcessInstanceKey(long)} @Index(name = "element_instance_processInstanceKeyIndex", columnList = "PROCESS_INSTANCE_KEY_"), }) public class ElementInstanceEntity { diff --git a/src/main/java/io/zeebe/monitor/entity/ErrorEntity.java b/src/main/java/io/zeebe/monitor/entity/ErrorEntity.java index 93169827..f20bd9dc 100644 --- a/src/main/java/io/zeebe/monitor/entity/ErrorEntity.java +++ b/src/main/java/io/zeebe/monitor/entity/ErrorEntity.java @@ -15,12 +15,14 @@ */ package io.zeebe.monitor.entity; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Lob; +import javax.persistence.*; @Entity(name = "ERROR") +@Table(indexes = { + // performance reason, because we use it in the + // {@link io.zeebe.monitor.repository.ErrorRepository#findByProcessInstanceKey(long)} + @Index(name = "error_processInstanceKeyIndex", columnList = "PROCESS_INSTANCE_KEY_"), +}) public class ErrorEntity { @Id diff --git a/src/main/java/io/zeebe/monitor/entity/IncidentEntity.java b/src/main/java/io/zeebe/monitor/entity/IncidentEntity.java index 7bdacc32..07b55577 100644 --- a/src/main/java/io/zeebe/monitor/entity/IncidentEntity.java +++ b/src/main/java/io/zeebe/monitor/entity/IncidentEntity.java @@ -15,12 +15,14 @@ */ package io.zeebe.monitor.entity; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Lob; +import javax.persistence.*; @Entity(name = "INCIDENT") +@Table(indexes = { + // performance reason, because we use it in the + // {@link io.zeebe.monitor.repository.IncidentRepository#findByProcessInstanceKey(long)} + @Index(name = "incident_processInstanceKeyIndex", columnList = "PROCESS_INSTANCE_KEY_"), +}) public class IncidentEntity { @Id diff --git a/src/main/java/io/zeebe/monitor/entity/JobEntity.java b/src/main/java/io/zeebe/monitor/entity/JobEntity.java index 3346ff73..53aab25b 100644 --- a/src/main/java/io/zeebe/monitor/entity/JobEntity.java +++ b/src/main/java/io/zeebe/monitor/entity/JobEntity.java @@ -15,11 +15,14 @@ */ package io.zeebe.monitor.entity; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; +import javax.persistence.*; @Entity(name = "JOB") +@Table(indexes = { + // performance reason, because we use it in the + // {@link io.zeebe.monitor.repository.JobRepository#findByProcessInstanceKey(long)} + @Index(name = "job_processInstanceKeyIndex", columnList = "PROCESS_INSTANCE_KEY_"), +}) public class JobEntity { @Id diff --git a/src/main/java/io/zeebe/monitor/entity/MessageSubscriptionEntity.java b/src/main/java/io/zeebe/monitor/entity/MessageSubscriptionEntity.java index 5eb37003..0229ae87 100644 --- a/src/main/java/io/zeebe/monitor/entity/MessageSubscriptionEntity.java +++ b/src/main/java/io/zeebe/monitor/entity/MessageSubscriptionEntity.java @@ -15,11 +15,14 @@ */ package io.zeebe.monitor.entity; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; +import javax.persistence.*; @Entity(name = "MESSAGE_SUBSCRIPTION") +@Table(indexes = { + // performance reason, because we use it in the + // {@link io.zeebe.monitor.repository.MessageSubscriptionRepository#findByProcessInstanceKey(long)} + @Index(name = "message_subscription_processInstanceKeyIndex", columnList = "PROCESS_INSTANCE_KEY_"), +}) public class MessageSubscriptionEntity { @Id diff --git a/src/main/java/io/zeebe/monitor/entity/TimerEntity.java b/src/main/java/io/zeebe/monitor/entity/TimerEntity.java index 760d0a16..db4a34a9 100644 --- a/src/main/java/io/zeebe/monitor/entity/TimerEntity.java +++ b/src/main/java/io/zeebe/monitor/entity/TimerEntity.java @@ -15,11 +15,14 @@ */ package io.zeebe.monitor.entity; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; +import javax.persistence.*; @Entity(name = "TIMER") +@Table(indexes = { + // performance reason, because we use it in the + // {@link io.zeebe.monitor.repository.TimerRepository#findByProcessInstanceKey(long)} + @Index(name = "timer_processInstanceKeyIndex", columnList = "PROCESS_INSTANCE_KEY_"), +}) public class TimerEntity { @Id