Skip to content

Audit log slows to a crawl when nearing 1 million entries #17689

Open
@mafredri

Description

@mafredri

Problem: Today, rendering the audit log on dev.coder.com takes over 1 minute for the first page.

When the audit log grows to a significant number of rows (currently 970714 entries at the time of writing for dev.coder.com), the pagination causes it to become slow.

The main culprit is the "total" count (COUNT(audit_logs.*) OVER () AS count) which converts the query from rendering N first results to reading the entire table as the count is based on applied filters.

Simply changing this out for (SELECT COUNT(*) FROM audit_logs) AS count makes the query instant, but of course, incorrect.

Solution: We must figure out a way to optimize the GetAuditLogsOffset query to show results faster.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions