Skip to content

perf: cap count queries, use native UUID ops for audit/conn logs (backport #23835)#24133

Open
geokat wants to merge 1 commit intorelease/2.30from
george/r230/backport-plat-31-connection-and-audit-logs-page-timeouts
Open

perf: cap count queries, use native UUID ops for audit/conn logs (backport #23835)#24133
geokat wants to merge 1 commit intorelease/2.30from
george/r230/backport-plat-31-connection-and-audit-logs-page-timeouts

Conversation

@geokat
Copy link
Copy Markdown
Contributor

@geokat geokat commented Apr 7, 2026

Backport of #23835.

Audit and connection log pages were timing out due to expensive COUNT(*) queries over large tables. This commit adds opt-in count capping: requests can return a count_cap field signaling that the count was truncated at a threshold, avoiding full table scans that caused page timeouts.

Text-cast UUID comparisons in regosql-generated authorization queries also contributed to the slowdown by preventing index usage for connection and audit log queries. These now emit native UUID operators.

Frontend changes handle the capped state in usePaginatedQuery and PaginationWidget, optionally displaying a capped count in the pagination UI (e.g. "Showing 2,076 to 2,100 of 2,000+ logs")


Cherry picked from 86ca61d

@github-actions github-actions bot added the community Pull Requests and issues created by the community. label Apr 7, 2026
@geokat geokat added cherry-pick/v2.30 Needs to be cherry-picked to the 2.30 release branch and removed community Pull Requests and issues created by the community. labels Apr 7, 2026
…kport #23835)

Audit and connection log pages were timing out due to expensive COUNT(*)
queries over large tables. This commit adds opt-in count capping: requests can
return a `count_cap` field signaling that the count was truncated at a threshold,
avoiding full table scans that caused page timeouts.

Text-cast UUID comparisons in regosql-generated authorization queries
also contributed to the slowdown by preventing index usage for connection
and audit log queries. These now emit native UUID operators.

Frontend changes handle the capped state in usePaginatedQuery and
PaginationWidget, optionally displaying a capped count in the pagination
UI (e.g. "Showing 2,076 to 2,100 of 2,000+ logs")

---

Cherry picked from 86ca61d
@geokat geokat force-pushed the george/r230/backport-plat-31-connection-and-audit-logs-page-timeouts branch from fa17cd3 to b9717d8 Compare April 7, 2026 23:11
@geokat geokat marked this pull request as ready for review April 7, 2026 23:49
@geokat geokat requested a review from Emyrk as a code owner April 7, 2026 23:49
@geokat geokat requested a review from f0ssel April 7, 2026 23:49
@coder-tasks
Copy link
Copy Markdown
Contributor

coder-tasks bot commented Apr 7, 2026

Documentation Check

No Changes Needed

This PR is a performance backport (#23835) that:

  • Adds a count_cap field to audit log and connection log API responses to avoid expensive full-table COUNT(*) scans on large deployments
  • Updates frontend pagination to display approximate counts (e.g. "2,000+ logs") when the count is capped

The API reference docs (docs/reference/api/audit.md, docs/reference/api/enterprise.md, docs/reference/api/schemas.md) are auto-generated and already updated in the diff. The UI behavior change (showing "N+" for large result sets) is self-explanatory and doesn't require additional admin documentation. The existing audit-logs and connection-logs admin pages don't document pagination internals, and adding a note about count approximation would be disproportionate to the scope of this fix.


Automated review via Coder Tasks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick/v2.30 Needs to be cherry-picked to the 2.30 release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant