Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore(coderd/database): optimize AuditLogs queries (cherry-pick #18600)#19193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

ethanndickson
Copy link
Member

@ethanndicksonethanndickson commentedAug 6, 2025
edited
Loading

A customer who recently upgraded their deployment to 2.24 is seeing their audit log queries take longer than a minute to load (resulting in a gateway timeout). As such, Support's requested we backport this fix to 2.24 (in the next patch), as it does not require a database migration.

Original PR Description (#18600):

Closes#17689

This PR optimizes the audit logs query performance by extracting the count operation into a separate query and replacing the OR-based workspace_builds with conditional joins.

Query changes

  • Extracted count query to separate one
  • Replaced singleworkspace_builds join with OR conditions with separate 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/4g1hbedg4a564bg8

New CountAuditLogs query:
https://explain.dalibo.com/plan/ga2fbcecb9efbce3

@coderabbitaicoderabbitai

This comment was marked as outdated.

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/ga2fbcecb9efbce3
@ethanndicksonethanndicksonforce-pushed theethan/2.24-audit-log-optimization-backport branch from97a3fc2 toa788e2fCompareAugust 6, 2025 03:12
@ethanndicksonethanndickson changed the titlechore: backport audit log query optimization to 2.24chore(coderd/database): optimize AuditLogs queries (cherry-pick #18600)Aug 7, 2025
@ethanndicksonethanndickson merged commit5ff7496 intorelease/2.24Aug 7, 2025
36 checks passed
@ethanndicksonethanndickson deleted the ethan/2.24-audit-log-optimization-backport branchAugust 7, 2025 12:21
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsAug 7, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@kacpersawkacpersawkacpersaw approved these changes

@stirbystirbyAwaiting requested review from stirby

Assignees

@ethanndicksonethanndickson

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@ethanndickson@kacpersaw

[8]ページ先頭

©2009-2025 Movatter.jp