Repository navigation
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)
Codex helped identify the query, prepare the patch and tests, and benchmark the SQL.
Fixes: #1293