Commit f0ddeef
#AI commit# CC: 优化作业执行列表查询性能:修复PageHelper分页失效与N+1,新增自定义count与索引DDL
1. 修复 getExecutedJobList 分页失效:PageHelper.startPage 在 current/size 校正之前调用,
且调用方无 defaultValue 的基本类型 int 在前端不传时绑定为0,startPage(0,0) 不追加 LIMIT
导致 getAllLaunchedJob 全表加载;将校正前置恢复 DB 层分页。
2. 消除 N+1:循环内逐个 selectTaskListByJobExecutionId 改为一次性批量 IN 查询
selectTaskMetricsByJobExecutionIds(仅取 job_execution_id/engine_type/metrics 三列),
内存按 jobExecutionId 分组计算 flow,逻辑等价。
3. 优化 count 查询:新增 getAllLaunchedJob_COUNT,PageHelper 按 _COUNT 后缀匹配,
只 count 单表 exchangis_launched_job_entity,去掉原 LEFT/INNER JOIN 的全表 JOIN count。
4. 新增阶段耗时日志:queryJob[count+paged]/queryTask/map/flow/jobCount/taskCount/pageTotal。
5. DDL:为 exchangis_launched_task_entity.job_execution_id 与
exchangis_launched_job_entity.create_time 添加索引,消除全表扫描与 filesort。
Optimize getExecutedJobList performance: fix PageHelper pagination failure and N+1, add custom count and index DDL
1. Fix pagination failure: PageHelper.startPage was called before current/size
validation, and the caller's primitive int params (no defaultValue) bound to 0
when absent from the frontend; startPage(0,0) skips LIMIT and loads all jobs.
Move validation before startPage to restore DB-level pagination.
2. Eliminate N+1: per-job selectTaskListByJobExecutionId in the loop is replaced by a
single batch IN query selectTaskMetricsByJobExecutionIds (only job_execution_id/
engine_type/metrics columns), grouped in memory by jobExecutionId to compute flow;
logic is equivalent.
3. Optimize count query: add getAllLaunchedJob_COUNT (matched by PageHelper via the
_COUNT suffix) that counts only exchangis_launched_job_entity, dropping the full
LEFT/INNER JOIN count of the original SQL.
4. Add per-stage timing logs: queryJob[count+paged]/queryTask/map/flow/jobCount/
taskCount/pageTotal.
5. DDL: add indexes on exchangis_launched_task_entity.job_execution_id and
exchangis_launched_job_entity.create_time to remove full table scans and filesort.
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 85b10cd commit f0ddeef
5 files changed
Lines changed: 112 additions & 8 deletions
File tree
- db/1.1.17
- exchangis-job/exchangis-job-server/src/main/java/com/webank/wedatasphere/exchangis/job/server
- mapper
- impl
- service/impl
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
105 | 113 | | |
106 | 114 | | |
107 | 115 | | |
| |||
Lines changed: 33 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
235 | 268 | | |
236 | 269 | | |
237 | 270 | | |
| |||
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
207 | 224 | | |
208 | 225 | | |
209 | 226 | | |
| |||
Lines changed: 47 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
274 | | - | |
| 274 | + | |
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
279 | 279 | | |
280 | 280 | | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
281 | 285 | | |
282 | 286 | | |
283 | 287 | | |
284 | 288 | | |
| 289 | + | |
| 290 | + | |
285 | 291 | | |
286 | 292 | | |
287 | 293 | | |
| 294 | + | |
288 | 295 | | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
289 | 325 | | |
290 | 326 | | |
291 | 327 | | |
| 328 | + | |
292 | 329 | | |
293 | 330 | | |
294 | 331 | | |
| |||
299 | 336 | | |
300 | 337 | | |
301 | 338 | | |
302 | | - | |
| 339 | + | |
| 340 | + | |
303 | 341 | | |
304 | 342 | | |
305 | 343 | | |
306 | 344 | | |
307 | 345 | | |
| 346 | + | |
308 | 347 | | |
309 | | - | |
310 | | - | |
311 | 348 | | |
312 | | - | |
313 | 349 | | |
314 | 350 | | |
| 351 | + | |
| 352 | + | |
315 | 353 | | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | 354 | | |
320 | 355 | | |
| 356 | + | |
321 | 357 | | |
322 | 358 | | |
323 | 359 | | |
| |||
326 | 362 | | |
327 | 363 | | |
328 | 364 | | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
329 | 368 | | |
330 | 369 | | |
331 | 370 | | |
| |||
0 commit comments