Skip to content

Conversation

armenzg
Copy link
Member

@armenzg armenzg commented Oct 3, 2025

Adds a composite index on group_id and datetime to the Activity model.

This index improves query performance for filtering and ordering activity records by group and datetime, which is a common access pattern for activity feeds.

A new migration (0996_add_activity_group_datetime_index.py) was created and marked as is_post_deployment = True to allow for manual execution on large tables without blocking deployments.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.


Slack Thread

Open in Cursor Open in Web

Co-authored-by: armenzg <armenzg@sentry.io>
Copy link
Contributor

cursor bot commented Oct 3, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 3, 2025
Copy link

codecov bot commented Oct 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff            @@
##           master   #100899   +/-   ##
========================================
  Coverage   81.15%    81.15%           
========================================
  Files        8616      8616           
  Lines      382267    382263    -4     
  Branches    24032     24031    -1     
========================================
- Hits       310211    310210    -1     
+ Misses      71728     71725    -3     
  Partials      328       328           

indexes = (models.Index(fields=("project", "datetime")),)
indexes = (
models.Index(fields=("project", "datetime")),
models.Index(fields=("group_id", "datetime")),
Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

github-actions bot commented Oct 3, 2025

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

for 0996_add_activity_group_datetime_index in sentry

--
-- Create index sentry_activity_group_datetime_idx on field(s) group_id, datetime of model activity
--
CREATE INDEX CONCURRENTLY "sentry_activity_group_datetime_idx" ON "sentry_activity" ("group_id", "datetime");

@armenzg armenzg closed this Oct 7, 2025
@armenzg armenzg deleted the cursor/add-index-to-activity-table-bb9d branch October 7, 2025 12:53
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