Commit 171a28c
authored
PERF: Optimize reviewable queries by eager loading (#36618)
Improved query performance by eagerly loading user_stat, primary_email,
and topic/category associations when fetching the target. This prevents
N+1 queries when accessing these commonly-needed associations in the
reviewables list.
In addition, running count is breaking eager_loading and causing N+1.
Using goldiload to prevent it.
Before
<img width="846" height="169" alt="Screenshot 2025-12-11 at 11 30 09 am"
src="https://github.com/user-attachments/assets/6053ca8f-edd6-4488-8db2-7ec196fe1196"
/>
After
<img width="843" height="170" alt="Screenshot 2025-12-11 at 2 21 02 pm"
src="https://github.com/user-attachments/assets/1d0f414c-8872-4c9f-9f32-080fd8a7b67c"
/>1 parent 5a8a035 commit 171a28c
File tree
4 files changed
+39
-11
lines changed- app
- models
- serializers
- spec/models
4 files changed
+39
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
462 | 462 | | |
463 | 463 | | |
464 | 464 | | |
465 | | - | |
466 | | - | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
467 | 475 | | |
468 | 476 | | |
469 | 477 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
| |||
1329 | 1330 | | |
1330 | 1331 | | |
1331 | 1332 | | |
1332 | | - | |
| 1333 | + | |
1333 | 1334 | | |
1334 | 1335 | | |
1335 | 1336 | | |
| |||
1345 | 1346 | | |
1346 | 1347 | | |
1347 | 1348 | | |
1348 | | - | |
| 1349 | + | |
1349 | 1350 | | |
1350 | 1351 | | |
1351 | 1352 | | |
| |||
1638 | 1639 | | |
1639 | 1640 | | |
1640 | 1641 | | |
1641 | | - | |
| 1642 | + | |
| 1643 | + | |
| 1644 | + | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
1642 | 1648 | | |
1643 | 1649 | | |
1644 | 1650 | | |
| |||
1650 | 1656 | | |
1651 | 1657 | | |
1652 | 1658 | | |
1653 | | - | |
| 1659 | + | |
| 1660 | + | |
| 1661 | + | |
| 1662 | + | |
| 1663 | + | |
| 1664 | + | |
1654 | 1665 | | |
1655 | 1666 | | |
1656 | 1667 | | |
1657 | | - | |
| 1668 | + | |
| 1669 | + | |
| 1670 | + | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
1658 | 1674 | | |
1659 | 1675 | | |
1660 | 1676 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2134 | 2134 | | |
2135 | 2135 | | |
2136 | 2136 | | |
2137 | | - | |
| 2137 | + | |
2138 | 2138 | | |
2139 | 2139 | | |
2140 | 2140 | | |
| |||
2158 | 2158 | | |
2159 | 2159 | | |
2160 | 2160 | | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
2161 | 2165 | | |
2162 | 2166 | | |
2163 | 2167 | | |
| |||
0 commit comments