Skip to content

fix(db): drop the unused plain env_builds status index - #3397

Closed
ValentaTomas wants to merge 4 commits into
mainfrom
drop-idx-env-builds-status
Closed

ValentaTomas wants to merge 4 commits into
mainfrom
drop-idx-env-builds-status

Conversation

@ValentaTomas

Copy link
Copy Markdown
Member

Summary

idx_env_builds_status (plain btree on raw status) has a negligible number of lifetime scans in pg_stat_user_indexes. Status-filtered access runs on the purpose-built indexes instead (idx_env_builds_env_status_created, idx_env_builds_team_status_group, idx_env_builds_team_status_pagination, and the covering index including status_group).

env_builds is the most write-amplified table in the registry (0% HOT updates, 8 indexes), so every dropped index removes real WAL and dead-tuple volume from each build insert/supersede.

Draft on purpose: requesting an owner's confirmation that nothing planned depends on a full-table raw-status scan path before this lands.

@cla-bot cla-bot Bot added the cla-signed label Jul 25, 2026
@cursor

cursor Bot commented Jul 25, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Dropping an index on a ~330M-row hot table can still block or slow workloads if anything still relies on full-table status scans; the down path is a long manual concurrent rebuild.

Overview
This removes the plain btree index on raw env_builds.status because it is barely used while every build insert still maintains it; status-filtered queries are expected to use the newer composite and status_group indexes instead. The migration uses DROP INDEX CONCURRENTLY with a one-hour statement_timeout on up and restores the migrator’s three-hour default afterward; down clears any invalid leftover index, rebuilds concurrently with no timeout for manual rollback, then restores the three-hour default.

Reviewed by Cursor Bugbot for commit 428983f. Bugbot is set up for automated code reviews on this repo. Configure here.

@ValentaTomas

Copy link
Copy Markdown
Member Author

closing for now, will revisit

@ValentaTomas
ValentaTomas deleted the drop-idx-env-builds-status branch August 15, 2026 04:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant