Commit 52d544e
PERF: Optimize CategoryList#relevant_topics_query SQL query (stable backport) (#36571)
Topics marked as category featured topics should always have
`Topic#category_id` set so the `topics.category_id is null` predicate is
not necessary. Profiling the query also reviewes that the
`topics.category_id is null`
predicate is causing the PG planner to do a seq scan against the topics
table on large sites.
Backports #36476
Co-authored-by: Alan Guo Xiang Tan <[email protected]>1 parent 5d3dd30 commit 52d544e
File tree
3 files changed
+22
-3
lines changed- app/models
- spec/models
3 files changed
+22
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
80 | 84 | | |
81 | 85 | | |
82 | 86 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
366 | 366 | | |
367 | 367 | | |
368 | 368 | | |
369 | | - | |
| 369 | + | |
370 | 370 | | |
371 | 371 | | |
372 | 372 | | |
| |||
377 | 377 | | |
378 | 378 | | |
379 | 379 | | |
| 380 | + | |
| 381 | + | |
380 | 382 | | |
381 | | - | |
| 383 | + | |
382 | 384 | | |
383 | 385 | | |
384 | 386 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2543 | 2543 | | |
2544 | 2544 | | |
2545 | 2545 | | |
| 2546 | + | |
| 2547 | + | |
| 2548 | + | |
| 2549 | + | |
| 2550 | + | |
| 2551 | + | |
| 2552 | + | |
| 2553 | + | |
| 2554 | + | |
| 2555 | + | |
| 2556 | + | |
| 2557 | + | |
| 2558 | + | |
2546 | 2559 | | |
2547 | 2560 | | |
2548 | 2561 | | |
| |||
0 commit comments