- Notifications
You must be signed in to change notification settings - Fork1k
Commit5ff7496
A customer who recently upgraded their deployment to 2.24 is seeingtheir audit log queries take longer than a minute to load (resulting ina gateway timeout). As such, Support's requested we backport this fix to2.24 (in the next patch), as it does not require a database migration.### Original PR Description (#18600):Closes#17689This PR optimizes the audit logs query performance by extracting thecount operation into a separate query and replacing the OR-basedworkspace_builds with conditional joins.## Query changes* Extracted count query to separate one* Replaced single `workspace_builds` join with OR conditions withseparate conditional joins* Added conditional joins* `wb_build` for workspace_build audit logs (which is a direct lookup) * `wb_workspace` for workspace create audit logs (via workspace)Optimized AuditLogsOffset query:https://explain.dalibo.com/plan/4g1hbedg4a564bg8New CountAuditLogs query:https://explain.dalibo.com/plan/ga2fbcecb9efbce3Co-authored-by: Kacper Sawicki <kacper@coder.com>
1 parent7f6cefd commit5ff7496
File tree
15 files changed
+763
-244
lines changed- coderd
- database
- dbauthz
- dbmem
- dbmetrics
- dbmock
- queries
- searchquery
15 files changed
+763
-244
lines changedOriginal file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
46 | 46 |
| |
47 | 47 |
| |
48 | 48 |
| |
49 |
| - | |
| 49 | + | |
50 | 50 |
| |
51 | 51 |
| |
52 | 52 |
| |
| |||
62 | 62 |
| |
63 | 63 |
| |
64 | 64 |
| |
| 65 | + | |
| 66 | + | |
65 | 67 |
| |
66 | 68 |
| |
67 |
| - | |
| 69 | + | |
| 70 | + | |
68 | 71 |
| |
69 | 72 |
| |
70 | 73 |
| |
| |||
73 | 76 |
| |
74 | 77 |
| |
75 | 78 |
| |
76 |
| - | |
77 |
| - | |
78 |
| - | |
| 79 | + | |
| 80 | + | |
79 | 81 |
| |
80 | 82 |
| |
81 | 83 |
| |
82 | 84 |
| |
83 | 85 |
| |
84 | 86 |
| |
85 | 87 |
| |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
86 | 98 |
| |
87 | 99 |
| |
88 |
| - | |
| 100 | + | |
89 | 101 |
| |
90 | 102 |
| |
91 | 103 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1301 | 1301 |
| |
1302 | 1302 |
| |
1303 | 1303 |
| |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
1304 | 1320 |
| |
1305 | 1321 |
| |
1306 | 1322 |
| |
| |||
5256 | 5272 |
| |
5257 | 5273 |
| |
5258 | 5274 |
| |
| 5275 | + | |
| 5276 | + | |
| 5277 | + | |
| 5278 | + |
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
327 | 327 |
| |
328 | 328 |
| |
329 | 329 |
| |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
330 | 340 |
| |
331 | 341 |
| |
332 | 342 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
271 | 271 |
| |
272 | 272 |
| |
273 | 273 |
| |
274 |
| - | |
| 274 | + | |
275 | 275 |
| |
276 | 276 |
| |
277 | 277 |
| |
| |||
296 | 296 |
| |
297 | 297 |
| |
298 | 298 |
| |
299 |
| - | |
300 |
| - | |
| 299 | + | |
| 300 | + | |
301 | 301 |
| |
302 | 302 |
| |
303 | 303 |
| |
| |||
308 | 308 |
| |
309 | 309 |
| |
310 | 310 |
| |
311 |
| - | |
| 311 | + | |
312 | 312 |
| |
313 | 313 |
| |
314 | 314 |
| |
315 | 315 |
| |
316 | 316 |
| |
317 | 317 |
| |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
318 | 325 |
| |
319 | 326 |
| |
320 | 327 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1779 | 1779 |
| |
1780 | 1780 |
| |
1781 | 1781 |
| |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
1782 | 1786 |
| |
1783 | 1787 |
| |
1784 | 1788 |
| |
| |||
13930 | 13934 |
| |
13931 | 13935 |
| |
13932 | 13936 |
| |
13933 |
| - | |
13934 | 13937 |
| |
13935 | 13938 |
| |
13936 | 13939 |
| |
13937 | 13940 |
| |
13938 | 13941 |
| |
13939 | 13942 |
| |
13940 | 13943 |
| |
13941 |
| - | |
13942 |
| - | |
13943 |
| - | |
| 13944 | + | |
| 13945 | + | |
| 13946 | + | |
| 13947 | + | |
| 13948 | + | |
| 13949 | + | |
13944 | 13950 |
| |
13945 | 13951 |
| |
13946 |
| - | |
| 13952 | + | |
| 13953 | + | |
| 13954 | + | |
| 13955 | + | |
| 13956 | + | |
| 13957 | + | |
| 13958 | + | |
| 13959 | + | |
| 13960 | + | |
| 13961 | + | |
| 13962 | + | |
| 13963 | + | |
| 13964 | + | |
| 13965 | + | |
| 13966 | + | |
| 13967 | + | |
| 13968 | + | |
| 13969 | + | |
| 13970 | + | |
| 13971 | + | |
| 13972 | + | |
| 13973 | + | |
| 13974 | + | |
| 13975 | + | |
| 13976 | + | |
| 13977 | + | |
| 13978 | + | |
| 13979 | + | |
| 13980 | + | |
| 13981 | + | |
| 13982 | + | |
| 13983 | + | |
| 13984 | + | |
| 13985 | + | |
| 13986 | + | |
| 13987 | + | |
| 13988 | + | |
| 13989 | + | |
| 13990 | + | |
| 13991 | + | |
| 13992 | + | |
| 13993 | + | |
| 13994 | + | |
| 13995 | + | |
| 13996 | + | |
| 13997 | + | |
| 13998 | + | |
| 13999 | + | |
| 14000 | + | |
| 14001 | + | |
| 14002 | + | |
| 14003 | + | |
| 14004 | + | |
| 14005 | + | |
| 14006 | + | |
| 14007 | + | |
| 14008 | + | |
| 14009 | + | |
| 14010 | + | |
| 14011 | + | |
| 14012 | + | |
| 14013 | + | |
| 14014 | + | |
| 14015 | + | |
| 14016 | + | |
| 14017 | + | |
| 14018 | + | |
| 14019 | + | |
| 14020 | + | |
| 14021 | + | |
13947 | 14022 |
|
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
478 | 478 |
| |
479 | 479 |
| |
480 | 480 |
| |
| 481 | + | |
481 | 482 |
| |
482 | 483 |
| |
483 | 484 |
| |
| |||
548 | 549 |
| |
549 | 550 |
| |
550 | 551 |
| |
551 |
| - | |
552 | 552 |
| |
553 | 553 |
| |
554 | 554 |
| |
| |||
563 | 563 |
| |
564 | 564 |
| |
565 | 565 |
| |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
566 | 614 |
| |
567 | 615 |
| |
568 | 616 |
| |
|
0 commit comments
Comments
(0)