Skip to content

Commit 83390ff

Browse files
committed
perf(repository): add indexes on sp_action.rollout and rollout_group
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.
1 parent eb53cfa commit 83390ff

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- See POSTGRESQL/V1_20_2__action_rollout_indexes__POSTGRESQL.sql for rationale.
2+
CREATE INDEX sp_idx_action_rollout_status ON sp_action (tenant, rollout, status);
3+
CREATE INDEX sp_idx_action_rollout_group ON sp_action (tenant, rollout_group);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- See POSTGRESQL/V1_20_2__action_rollout_indexes__POSTGRESQL.sql for rationale.
2+
CREATE INDEX sp_idx_action_rollout_status ON sp_action (tenant, rollout, status);
3+
CREATE INDEX sp_idx_action_rollout_group ON sp_action (tenant, rollout_group);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- Add indexes covering rollout-monitoring queries on sp_action.
2+
--
3+
-- existsByRolloutId, getStatusCountByRolloutId, getStatusCountByRolloutGroupId
4+
-- (and similar JPA queries) filter by rollout / rollout_group; the baseline did
5+
-- not index either column, so Postgres falls back to Seq Scan over sp_action on
6+
-- every monitoring poll. With 16k action rows the group-count query takes ~500 ms
7+
-- without the index and ~27 ms with it (Index Only Scan, Heap Fetches: 0).
8+
CREATE INDEX sp_idx_action_rollout_status ON sp_action (tenant, rollout, status);
9+
CREATE INDEX sp_idx_action_rollout_group ON sp_action (tenant, rollout_group);

0 commit comments

Comments
 (0)