sentry icon indicating copy to clipboard operation
sentry copied to clipboard

perf(group): add type index to improve querying on groups

Open barkbarkimashark opened this issue 3 years ago • 1 comments

Adds a compound index ("project", "type", "status", "last_seen", "id") to improve query performance.

Growth team is currently observing timeouts for large projects so this is required.

Fixes WOR-2122

barkbarkimashark avatar Sep 19 '22 19:09 barkbarkimashark

This PR has a migration; here is the generated SQL for src/sentry/migrations/0317_groupedmessage_type_index.py ()

--
-- Custom state/database change combination
--

                    CREATE INDEX CONCURRENTLY IF NOT EXISTS "sentry_groupedmessage_project_id_type_status_l_074196b6_idx" ON "sentry_groupedmessage" ("project_id", "status", "type", "last_seen", "id");
                    ;

github-actions[bot] avatar Sep 19 '22 19:09 github-actions[bot]

  1. are there any other query patterns besides here this is intending to help? I'm wondering if it may be more advantageous to switch the order of type and status, since when we filter on type it seems like it will usually be a range, which means that status will only be used as a filter.

Good callout! I think your suggestion makes sense. I made the change - let me know if I need to make any other changes.

barkbarkimashark avatar Sep 21 '22 23:09 barkbarkimashark