Commit 2fc7a8e
perf: fix N+1 queries with batch author/category loading
Replace per-article userMapper.selectById() and categoryService.resolveMeta()
calls in bulk paths with a new mapListItems() that preloads all authors via
selectBatchIds() and caches category metas per unique ID.
Affected callers:
- listPublished() — public article list
- listMine() — user's own article list
- ArticleSearchService.searchByEs() — ES search results
- ArticleSearchService.searchByMysql() — MySQL fallback search
Before: 20 articles = 1 + 20 author queries + 20 category queries = 41 DB calls
After: 20 articles = 1 + 1 author query + N unique categories = 2–5 DB calls
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 3e3d7dd commit 2fc7a8e
4 files changed
Lines changed: 58 additions & 11 deletions
File tree
- .superpowers/brainstorm/1761-1782143253/state
- OpenBlog-business/src/main/java/com/yqz/openblog
- article/service
- search/service
This file was deleted.
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
Lines changed: 53 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
28 | | - | |
| 26 | + | |
| 27 | + | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
| |||
86 | 85 | | |
87 | 86 | | |
88 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
89 | 137 | | |
90 | 138 | | |
91 | 139 | | |
| |||
187 | 235 | | |
188 | 236 | | |
189 | 237 | | |
190 | | - | |
| 238 | + | |
191 | 239 | | |
192 | 240 | | |
193 | 241 | | |
| |||
396 | 444 | | |
397 | 445 | | |
398 | 446 | | |
399 | | - | |
| 447 | + | |
400 | 448 | | |
401 | 449 | | |
402 | 450 | | |
| |||
Lines changed: 4 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
| 84 | + | |
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
| |||
127 | 128 | | |
128 | 129 | | |
129 | 130 | | |
130 | | - | |
131 | | - | |
132 | | - | |
| 131 | + | |
133 | 132 | | |
134 | 133 | | |
135 | 134 | | |
| |||
0 commit comments