Skip to content

Aggregate job runs before joining the class registry - #1292

Open
melroy89 wants to merge 1 commit into
nextcloud:masterfrom
melroy89:perf/aggregate-job-stats-before-class-join
Open

melroy89 wants to merge 1 commit into
nextcloud:masterfrom
melroy89:perf/aggregate-job-stats-before-class-join

Conversation

@melroy89

@melroy89 melroy89 commented Nov 22, 2026 •

Copy link
Copy Markdown

The scheduled slowest-jobs refresh looks up the job class for each retained run before grouping. As the history grows, that repeats the same registry lookup many times.

The new query groups finished runs by job type and calculates the statistics first. Then it looks up the name of each job type once. If the file scanner ran 10,000 times, MariaDB still reads all 10,000 runs, but it can look up “File scanner” once instead of 10,000 times.

The run count, average and maximum duration, and peak memory stay the same. Running jobs and runs without a registered class are still excluded. When two job types have the same average duration, class ID determines their order.

On a MariaDB 10.11.14 fixture with 630,000 runs, median query time fell from 209 ms to 124 ms across ten alternating runs. The 92 result rows matched.

I ran the Server Info refresh on a local Nextcloud Server 36.0.0 dev instance (36.0.0.2) with SQLite. It returned the expected cached statistics.

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI (N/A)

Codex helped identify the query, prepare the patch and tests, and benchmark the SQL.

Fixes: #1293

Refreshing the slowest jobs cache can read hundreds of thousands of retained runs. Avoid repeated class registry lookups so the scheduled refresh spends less time in the database.

Assisted-by: Codex:gpt-6
Signed-off-by: Melroy van den Berg <melroy@melroy.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Server Info’s slowest-jobs refresh gets expensive as job history grows

1 participant