Commit dbb0dd2
perf(issues): Fix N+1 queries in starred views endpoint
The starred views serializer was calling serialize() per item, which
triggered separate get_attrs() calls for each starred view — roughly
4N+1 queries for N views. Batch-serialize all views in get_attrs()
instead.
Also adds prefetch_related for the projects M2M and switches
values_list() to .all() so the prefetch cache is actually used.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 0be518e commit dbb0dd2
File tree
3 files changed
+16
-12
lines changed- src/sentry
- api/serializers/models
- issues/endpoints
3 files changed
+16
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| |||
Lines changed: 8 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
| |||
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
31 | | - | |
32 | | - | |
33 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
34 | 34 | | |
35 | | - | |
36 | | - | |
37 | | - | |
| 35 | + | |
38 | 36 | | |
| 37 | + | |
39 | 38 | | |
40 | | - | |
| 39 | + | |
| 40 | + | |
Lines changed: 7 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | | - | |
36 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
37 | 41 | | |
38 | 42 | | |
39 | 43 | | |
| |||
0 commit comments