Skip to content

fix(db): drop duplicate snapshots sandbox_id index - #3396

Closed
ValentaTomas wants to merge 4 commits into
mainfrom
drop-idx-snapshots-sandbox-id
Closed

ValentaTomas wants to merge 4 commits into
mainfrom
drop-idx-snapshots-sandbox-id

Conversation

@ValentaTomas

Copy link
Copy Markdown
Member

Summary

idx_snapshots_sandbox_id is an exact duplicate of snapshots_sandbox_id_unique (same single column, same order). The unique index serves all lookups; the copy has 0 lifetime scans in pg_stat_user_indexes, while every snapshot write maintains it for nothing.

DROP INDEX CONCURRENTLY with the same timeout/INVALID-leftover handling as the recent drop-index precedent. Down rebuilds it concurrently (unbounded timeout, manual operation by design).

@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

Low Risk
Read-path coverage stays on the existing unique constraint; the change is a concurrent index drop with established timeout and rollback handling on a large table.

Overview
Removes the redundant non-unique idx_snapshots_sandbox_id index on snapshots.sandbox_id because it mirrors snapshots_sandbox_id_unique and only adds write overhead. The migration drops it with DROP INDEX CONCURRENTLY, uses a bounded statement_timeout for the Up path and restores the migrator’s 3h session default afterward; Down can rebuild the index concurrently with unbounded timeout and clears any INVALID leftover first.

Reviewed by Cursor Bugbot for commit 1670e07. 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-snapshots-sandbox-id 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