Skip to content

ref(db): Drop unused Group.logger indexes - #128334

Merged
beezz merged 1 commit into
masterfrom
junior/drop-group-logger-indexes
Oct 21, 2026
Merged

beezz merged 1 commit into
masterfrom
junior/drop-group-logger-indexes

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Drops the two indexes that db_index=True creates on Group.logger:

  • sentry_groupedmessage_logger_993cb6d5, a btree on logger
  • sentry_groupedmessage_logger_993cb6d5_like, a btree on logger varchar_pattern_ops that Django adds for LIKE lookups on CharFields

This is a follow-up to #128156 (level) and #128165 (times_seen).

Why

  • Nothing in src/ filters, orders, or runs LIKE lookups on Group.logger in Postgres, so both indexes only add write overhead on sentry_groupedmessage.
  • Neither is unique or a constraint.

How

Same pattern as 1228/1229:

  • Removed db_index=True from Group.logger.
  • Migration 1231_drop_group_logger_indexes uses SeparateDatabaseAndState:
    • The database side runs DROP INDEX CONCURRENTLY IF EXISTS for both Django names, and for the South-era names sentry_groupedmessage_logger and sentry_groupedmessage_logger_like. Dropping by exact name keeps AlterField from introspecting and dropping other indexes.
    • The state side is an AlterField matching the model.
    • use_statement_timeout=False, because the concurrent drops wait for open transactions.
    • is_post_deployment = True.
    • Reversible: the reverse SQL recreates both indexes under their current names, including varchar_pattern_ops on the _like index.

Notes for reviewers

  • SafeRunSQL needs sign-off from owners-migrations.
  • I couldn't run makemigrations --check or sqlmigrate locally, so please rely on CI and the migration SQL comment.

via michal.

--

View Junior Session in Sentry

Nothing queries Group by logger in Postgres, so the btree and
varchar_pattern_ops indexes created by db_index=True only add write
overhead. Drop them (and their South-era names) with
DROP INDEX CONCURRENTLY IF EXISTS as a post-deployment migration.

Co-Authored-By: michal <michal.kuffa@sentry.io>
@sentry-junior
sentry-junior Bot requested review from a team as code owners October 21, 2026 10:27
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR has a migration; here is the generated SQL for src/sentry/migrations/1231_drop_group_logger_indexes.py

for 1231_drop_group_logger_indexes in sentry

--
-- Custom state/database change combination
--
DROP INDEX CONCURRENTLY IF EXISTS "sentry_groupedmessage_logger_993cb6d5";
DROP INDEX CONCURRENTLY IF EXISTS "sentry_groupedmessage_logger_993cb6d5_like";
DROP INDEX CONCURRENTLY IF EXISTS "sentry_groupedmessage_logger";
DROP INDEX CONCURRENTLY IF EXISTS "sentry_groupedmessage_logger_like";

@beezz
beezz merged commit c040fbb into master Oct 21, 2026
90 checks passed
@beezz
beezz deleted the junior/drop-group-logger-indexes branch October 21, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants