Skip to content

Commit 8e117b0

Browse files
committed
Add active-status index for toolchain images
Add a new immutable SQL migration creating a partial index on `installed_toolchain_images(status)` for `installed` and `pending` rows. This aligns with `list_active_images` lookups used during hosted-runner Docker reconnect/prewarm cycles and keeps the query scalable as table size grows, while remaining a defensive optimization at current low cardinality.
1 parent 5ea55ff commit 8e117b0

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
-- Partial index matching `list_active_images` (db/toolchain_images.rs), which
2+
-- runs on every hosted-runner Docker reconnect (30-60 s during an outage) to
3+
-- build the prewarm set. A partial index over just the active rows keeps that
4+
-- lookup index-only regardless of table size.
5+
--
6+
-- Note: today the table is bounded to the toolchain catalog (toolchain_key is
7+
-- the primary key and only catalog keys are ever inserted, so ~10 rows max), so
8+
-- the planner may still seq-scan it — the index is defensive/forward-looking,
9+
-- not a hot-path necessity at current cardinality. Added as its own migration
10+
-- because migrations are immutable once applied (editing the create-table
11+
-- migration would fail sqlx's startup checksum check).
12+
CREATE INDEX IF NOT EXISTS installed_toolchain_images_active_idx
13+
ON installed_toolchain_images (status)
14+
WHERE status IN ('installed', 'pending');

0 commit comments

Comments
 (0)