NPlusOneDetector
API reference › Debug Core › Panel › Db › NPlusOneDetector
Detects repeated read queries emitted from one captured call site.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
bySequence() static | Indexes findings by every query sequence they cover, so a grid row can look up its own group. | NPlusOneDetector |
detect() static | Groups repeated SELECT statements by captured call site and keeps the groups above the threshold. | NPlusOneDetector |
Method details
Section titled “Method details”bySequence()
Section titled “bySequence() ”public static function bySequence(list<PHPForge\Debug\Panel\Db\NPlusOneFinding> $findings): array<int, PHPForge\Debug\Panel\Db\NPlusOneFinding>Indexes findings by every query sequence they cover, so a grid row can look up its own group.
Parameters
| Parameter | Type | Description |
|---|---|---|
$findings | list<NPlusOneFinding> | Findings to index. |
Returns
array<int, NPlusOneFinding>: Findings keyed by covered query sequence.
detect()
Section titled “detect() ”public static function detect(list<PHPForge\Debug\Panel\Db\QueryRow> $rows, int $threshold = 3): list<PHPForge\Debug\Panel\Db\NPlusOneFinding>Groups repeated SELECT statements by captured call site and keeps the groups above the threshold.
Parameters
| Parameter | Type | Description |
|---|---|---|
$rows | list<QueryRow> | Captured query rows in capture order. |
$threshold | int | Minimum occurrences a call site needs to be reported; must be at least 2. |
Returns
list<NPlusOneFinding>: Findings ordered by count, then total duration, then first sequence.
Throws
InvalidArgumentException: When the threshold is lower than2.