-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Hello,
Plugin contains nested database queries within loops, causing N+1 query problems that can severely impact performance on production sites with large datasets.
- How to fix:
- Move DB calls outside loops by preloading required records in bulk.
- Use
get_records_sql()with grouped queries andget_in_or_equal()where applicable. - Iterate over in-memory results instead of querying
$DBper loop iteration.
Documentation:
Code excerpts:
- File:
coursereport.php
239: // Verdict severity ordering for roll-up "worst" verdict.
240: $verdictseverity = [
241: 'LIKELY_HUMAN' => 0,
242: 'LOW_SUSPICION' => 1,
243: 'SUSPICIOUS' => 2,
244: 'PROBABLE_AGENT' => 3,
245: 'HIGH_CONFIDENCE_AGENT' => 4,
246: ];
248: foreach ($sessions as $session) {
249: $totalsessions++;
251: // Load the highest-scoring combined signal record for this session.
252: $signalrecord = $DB->get_record_sql(
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels