Fix: do not compute severity for tasks without a report - #3070
Open
TheBeast85 wants to merge 1 commit into
Open
Conversation
task_severity() passes the result of the last report lookup straight to
report_severity(), so for a task that never produced a report it calls
report_severity(NULL, ...). That returns NULL, but only after the whole
severity query has been evaluated, including the report_counts lookup and
the dynamic severity check.
The cost is per task, so it shows up wherever severity is aggregated over
many tasks - the task dashboard being the obvious one.
Look up the report in a FROM subquery instead and call report_severity with
its id. Without a report the subquery has no rows, the scalar subquery
yields NULL and report_severity is never called. The result is unchanged.
Measured on an installation with 4507 tasks, of which most have no report:
select task_severity(id,0,70), count(*) from tasks group by 1
before: 2782 ms after: 376 ms
The saving is proportional to the number of tasks that never ran; on an
installation where almost none of them have a report the same aggregate went
from 2774 ms to 9 ms. The severity distribution is identical either way.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
What
Look up the last report in a FROM subquery and pass its id to
report_severityWhy
task_severitypassed the report lookup straight toreport_severity, so a task that never produced a report calledreport_severity(NULL, ...). That returns NULL, but only after the whole severity query has been evaluated, including thereport_countslookup and the dynamic severity check. The cost is per task, so it shows up wherever severity is aggregated over many tasks.With the subquery there are no rows when the task has no report, so
report_severityis never called and the result is unchanged.On an installation with 4507 tasks the aggregate goes from 2782 ms to 376 ms. The saving is proportional to the number of tasks that never ran; where almost none of them have a report it was 2774 ms to 9 ms.
Checklist