From eba16e529e3e2764e7d65f4628e67e8e27b442b5 Mon Sep 17 00:00:00 2001 From: clayly <31773799+clayly@users.noreply.github.com> Date: Fri, 15 May 2026 10:54:39 +0300 Subject: [PATCH] Add indexes on sp_action.rollout and rollout_group (#3045) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * perf(repository): add indexes on sp_idx_action_rollout_group_status and sp_idx_action_rollout_status Rollout monitoring queries (existsByRolloutId, getStatusCountByRolloutId, getStatusCountByRolloutGroupId) filter by rollout or rollout_group on sp_action. The flyway baseline did not index either column, so Postgres falls back to Seq Scan on every monitoring poll. With 16k action rows this is meaningful — the group-count query takes ~500 ms without the index and ~27 ms with it (Index Only Scan, Heap Fetches: 0). Bench (16k rows, 1000 iter): - WHERE tenant=? AND rollout_group=? 18.6x faster on PG 17.6x faster on YugabyteDB - WHERE tenant=? AND rollout=? GROUP BY status 2.5x faster on PG 1.5x faster on YugabyteDB Adds V1_20_2 sibling migrations for POSTGRESQL, H2, and MYSQL. --- .../db/migration/H2/V1_20_2__action_rollout_indexes__H2.sql | 2 ++ .../migration/MYSQL/V1_20_2__action_rollout_indexes__MYSQL.sql | 2 ++ .../POSTGRESQL/V1_20_2__action_rollout_indexes__POSTGRESQL.sql | 2 ++ 3 files changed, 6 insertions(+) create mode 100644 hawkbit-repository/hawkbit-repository-jpa-flyway/src/main/resources/db/migration/H2/V1_20_2__action_rollout_indexes__H2.sql create mode 100644 hawkbit-repository/hawkbit-repository-jpa-flyway/src/main/resources/db/migration/MYSQL/V1_20_2__action_rollout_indexes__MYSQL.sql create mode 100644 hawkbit-repository/hawkbit-repository-jpa-flyway/src/main/resources/db/migration/POSTGRESQL/V1_20_2__action_rollout_indexes__POSTGRESQL.sql diff --git a/hawkbit-repository/hawkbit-repository-jpa-flyway/src/main/resources/db/migration/H2/V1_20_2__action_rollout_indexes__H2.sql b/hawkbit-repository/hawkbit-repository-jpa-flyway/src/main/resources/db/migration/H2/V1_20_2__action_rollout_indexes__H2.sql new file mode 100644 index 000000000..ae9ac8d1a --- /dev/null +++ b/hawkbit-repository/hawkbit-repository-jpa-flyway/src/main/resources/db/migration/H2/V1_20_2__action_rollout_indexes__H2.sql @@ -0,0 +1,2 @@ +CREATE INDEX sp_idx_action_rollout_status ON sp_action (tenant, rollout, status); +CREATE INDEX sp_idx_action_rollout_group_status ON sp_action (tenant, rollout_group, status); diff --git a/hawkbit-repository/hawkbit-repository-jpa-flyway/src/main/resources/db/migration/MYSQL/V1_20_2__action_rollout_indexes__MYSQL.sql b/hawkbit-repository/hawkbit-repository-jpa-flyway/src/main/resources/db/migration/MYSQL/V1_20_2__action_rollout_indexes__MYSQL.sql new file mode 100644 index 000000000..ae9ac8d1a --- /dev/null +++ b/hawkbit-repository/hawkbit-repository-jpa-flyway/src/main/resources/db/migration/MYSQL/V1_20_2__action_rollout_indexes__MYSQL.sql @@ -0,0 +1,2 @@ +CREATE INDEX sp_idx_action_rollout_status ON sp_action (tenant, rollout, status); +CREATE INDEX sp_idx_action_rollout_group_status ON sp_action (tenant, rollout_group, status); diff --git a/hawkbit-repository/hawkbit-repository-jpa-flyway/src/main/resources/db/migration/POSTGRESQL/V1_20_2__action_rollout_indexes__POSTGRESQL.sql b/hawkbit-repository/hawkbit-repository-jpa-flyway/src/main/resources/db/migration/POSTGRESQL/V1_20_2__action_rollout_indexes__POSTGRESQL.sql new file mode 100644 index 000000000..ae9ac8d1a --- /dev/null +++ b/hawkbit-repository/hawkbit-repository-jpa-flyway/src/main/resources/db/migration/POSTGRESQL/V1_20_2__action_rollout_indexes__POSTGRESQL.sql @@ -0,0 +1,2 @@ +CREATE INDEX sp_idx_action_rollout_status ON sp_action (tenant, rollout, status); +CREATE INDEX sp_idx_action_rollout_group_status ON sp_action (tenant, rollout_group, status);