fix(schema): index the join child columns monitor_id, alert_type_id and group_id #32

Merged
KofTwentyTwo merged 2 commits from feature/alerts-join-indexes into develop 2026-10-14 23:00:35 +00:00
KofTwentyTwo commented 2026-10-14 20:18:20 +00:00 (Migrated from github.com)

What

Changeset qbit-alerts:30 adds three indexes. It is additive and uses IF NOT EXISTS:

  • ix_alerts_alert_monitor_id_status on alerts_alert (monitor_id, status). MonitorEvaluator looks up a per-record monitor's open alerts by monitorId + status IN open on every evaluation (engine/MonitorEvaluator.java:282). The join alerts_monitor -> alerts_alert also uses it.
  • ix_alerts_monitor_alert_type_id on alerts_monitor (alert_type_id), for the "Monitors" section on the type record.
  • ix_alerts_type_group_id on alerts_type (group_id), for the "Alert Types" section on the group record and the group roll-ups.

Why

This came out of an index audit of the qbits installed on kof22. These three were the only one-to-many join child columns with no leading index.

Tests

  • New AlertsQBitProducerTest.testJoinChildColumnsAreIndexed checks every join in AlertsTableMetaDataHelper.buildJoins() against the shipped changelog. It accepts a CREATE INDEX, an inline UNIQUE, or a renamed ix_<table>_<column> index.
  • The test fails without changeset 29.
  • ./mvnw verify is green locally.

kof22 gets the same indexes now through its own dated changeset, so it does not need to wait for a release.

🤖 Generated with Claude Code

## What Changeset `qbit-alerts:30` adds three indexes. It is additive and uses `IF NOT EXISTS`: - `ix_alerts_alert_monitor_id_status` on `alerts_alert (monitor_id, status)`. `MonitorEvaluator` looks up a per-record monitor's open alerts by `monitorId` + `status IN open` on every evaluation (`engine/MonitorEvaluator.java:282`). The join `alerts_monitor -> alerts_alert` also uses it. - `ix_alerts_monitor_alert_type_id` on `alerts_monitor (alert_type_id)`, for the "Monitors" section on the type record. - `ix_alerts_type_group_id` on `alerts_type (group_id)`, for the "Alert Types" section on the group record and the group roll-ups. ## Why This came out of an index audit of the qbits installed on kof22. These three were the only one-to-many join child columns with no leading index. ## Tests - New `AlertsQBitProducerTest.testJoinChildColumnsAreIndexed` checks every join in `AlertsTableMetaDataHelper.buildJoins()` against the shipped changelog. It accepts a `CREATE INDEX`, an inline `UNIQUE`, or a renamed `ix_<table>_<column>` index. - The test fails without changeset 29. - `./mvnw verify` is green locally. kof22 gets the same indexes now through its own dated changeset, so it does not need to wait for a release. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.