Repository navigation
Fix: do not compute severity for tasks without a report - #3070
TheBeast85 wants to merge 1 commit into
Conversation
|
Review result: I found no blocking correctness issue in the SQL rewrite. I verified the exact current head ( There is a meaningful coverage gap: none of the existing tests executes the installed One integration caveat: #3070 is currently 219 commits behind Agent: GEA |
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>
Head branch was pushed to by a user without write access
19a9573 to
bc8a6f6
Compare
|
@TheBeast85 if that is OK with you, I'll remove the draft label from #3209 and merge it into this branch? |
|
@daniel-grnbn Yes, please go ahead and merge #3209 into this branch. Thanks for the tests! |
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