Skip to content

Commit 615ce47

Browse files
authored
Update Querycollector with SQLite Explain support (#1315)
This adds support for SQLite EXPLAIN statement. There is no support for EXPLAIN QUERY PLAN yet, as this would require more changes to the package config.
1 parent 9bb3381 commit 615ce47

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/DataCollector/QueryCollector.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,41 @@ public function collect()
511511
'type' => 'explain',
512512
];
513513
}
514+
} elseif ($query['driver'] === 'sqlite') {
515+
$vmi = '<table style="margin:-5px -11px !important;width: 100% !important">';
516+
$vmi .= "<thead><tr>
517+
<td>Address</td>
518+
<td>Opcode</td>
519+
<td>P1</td>
520+
<td>P2</td>
521+
<td>P3</td>
522+
<td>P4</td>
523+
<td>P5</td>
524+
<td>Comment</td>
525+
</tr></thead>";
526+
527+
foreach ($query['explain'] as $explain) {
528+
$vmi .= "<tr>
529+
<td>{$explain->addr}</td>
530+
<td>{$explain->opcode}</td>
531+
<td>{$explain->p1}</td>
532+
<td>{$explain->p2}</td>
533+
<td>{$explain->p3}</td>
534+
<td>{$explain->p4}</td>
535+
<td>{$explain->p5}</td>
536+
<td>{$explain->comment}</td>
537+
</tr>";
538+
}
539+
540+
$vmi .= '</table>';
541+
542+
$statements[] = [
543+
'sql' => " - EXPLAIN:",
544+
'type' => 'explain',
545+
'params' => [
546+
'Virtual Machine Instructions' => $vmi,
547+
]
548+
];
514549
} else {
515550
foreach ($query['explain'] as $explain) {
516551
$statements[] = [

0 commit comments

Comments
 (0)