Skip to content

feat(cells): add db migration for synapse#109615

Merged
lynnagara merged 1 commit intomasterfrom
synapse-add-index
Feb 27, 2026
Merged

feat(cells): add db migration for synapse#109615
lynnagara merged 1 commit intomasterfrom
synapse-add-index

Conversation

@lynnagara
Copy link
Copy Markdown
Member

@lynnagara lynnagara commented Feb 27, 2026

this migration replaces the single-column db_index=True on OrganizationMapping.date_updated with a composite expression index on (TruncSecond(date_updated), id), which matches the synapse paginator's order by and where clause.

this avoids expensive sequential scans or any additional sorting steps.

this is a post-deploy migration.

this migration replaces the single-column db_index=True on OrganizationMapping.date_updated with a composite expression index on (TruncSecond(date_updated), id), which matches the synapse paginator's order by and where clause.

this avoids expensive sequential scans or any additional sorting steps.
@lynnagara lynnagara requested a review from a team as a code owner February 27, 2026 21:15
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Feb 27, 2026
@github-actions
Copy link
Copy Markdown
Contributor

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

for 1036_orgmapping_date_updated_trunc_index in sentry

--
-- Create index sentry_orgmapping_date_updated_id_idx on TruncSecond(F(date_updated)), F(id) on model organizationmapping
--
CREATE INDEX CONCURRENTLY "sentry_orgmapping_date_updated_id_idx" ON "sentry_organizationmapping" ((DATE_TRUNC('second', "date_updated" AT TIME ZONE 'UTC')), "id");
--
-- Alter field date_updated on organizationmapping
--
DROP INDEX CONCURRENTLY IF EXISTS "sentry_organizationmapping_date_updated_cb5e0369";

disable_member_invite = models.BooleanField(default=False, db_default=False)

date_updated = models.DateTimeField(db_default=Now(), auto_now=True, db_index=True)
date_updated = models.DateTimeField(db_default=Now(), auto_now=True)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, I assume we don't use this specific index for other queries?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, the field was added recently for this project and hasn't been used yet

@lynnagara lynnagara merged commit 7954995 into master Feb 27, 2026
114 of 116 checks passed
@lynnagara lynnagara deleted the synapse-add-index branch February 27, 2026 21:57
jan-auer added a commit that referenced this pull request Mar 2, 2026
…ept-encoding

* origin/master: (63 commits)
  fix(api): Add missing cursor query parameter to paginated endpoint OpenAPI schemas (#109642)
  docs(sentry-apps): Add sentryAppId to sentry-app-installations API schema (#109628)
  feat(occurrences on eap): Implement double reads from EAP in organization events trace API endpoint (#109391)
  feat(occurrences on eap): Implement double reads from EAP for reprocessing2 flow (#109345)
  feat(ci): report backend test fails (#109543)
  feat(seer): Add signed viewer context header to Seer API requests (#109626)
  devenv: cleanup devenv-managed uv (#109617)
  feat(seer): Iterate on the instructions at the top of seer settings pages (#109586)
  ref(seer): Add typed wrappers for remaining Seer API callsites (#109607)
  feat(preprod): Make snapshots endpoint org scoped (#109575)
  chore: capture exception (#109620)
  fix(formatting): run ruff format (#109618)
  feat(preprod): Create admin gated recompare snapshots endpoint (#109546)
  feat(cells): expand locality/cell distinction (#109538)
  feat(cells): add db migration for synapse (#109615)
  feat(preprod): Add public install-details endpoint and shared utilities (#109583)
  fix(tests): Fix flaky test_cross_trace_query_with_spans_and_logs (#109572)
  fix(grouping): Resolve mypy possibly-undefined errors in grouphash caching (#109602)
  fix(dashboards): Default axisRange to auto for existing widgets in builder (#109598)
  fix(billing): Fix category display names in pending changes (#109612)
  ...
@github-actions github-actions bot locked and limited conversation to collaborators Mar 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants