mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2025-12-23 22:37:53 -05:00
Add EXPLAIN output to filter debug
This commit is contained in:
@@ -34,14 +34,58 @@
|
||||
?>
|
||||
<p><label>SQL</label>
|
||||
<?php
|
||||
$sql = 'SELECT E.*,M.Name AS MonitorName,M.DefaultScale<br/>FROM Monitors AS M INNER JOIN Events AS E ON (M.Id = E.MonitorId)<br/>WHERE<br/>';
|
||||
$sql = 'SELECT E.*,M.Name AS MonitorName,M.DefaultScale FROM Monitors AS M INNER JOIN Events AS E ON (M.Id = E.MonitorId)
|
||||
WHERE
|
||||
';
|
||||
$sql .= $filter->sql();
|
||||
$sql .= $filter->sort_field() ? ' ORDER BY '.$filter->sort_field(). ' ' .($filter->sort_asc() ? 'ASC' : 'DESC') : '';
|
||||
$sql .= $filter->limit() ? ' LIMIT '.$filter->limit() : '';
|
||||
$sql .= $filter->skip_locked() ? ' SKIP LOCKED' : '';
|
||||
#$sql .= $filter->skip_locked() ? ' SKIP LOCKED' : '';
|
||||
|
||||
echo $sql;
|
||||
|
||||
echo preg_replace('/\n/', '<br/>', $sql);
|
||||
?></p>
|
||||
<p><label>MySQL Explanation</label>
|
||||
<?php
|
||||
echo '
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Select Type</th>
|
||||
<th>Table</th>
|
||||
<th>Partitions</th>
|
||||
<th>Type</th>
|
||||
<th>Possible Keys</th>
|
||||
<th>Key</th>
|
||||
<th>Key Length</th>
|
||||
<th>Ref</th>
|
||||
<th>Rows</th>
|
||||
<th>Filtered</th>
|
||||
<th>Extra</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
';
|
||||
$result = dbFetchAll('EXPLAIN '.$sql);
|
||||
foreach ($result as $row) {
|
||||
echo '<tr>'.PHP_EOL.
|
||||
'<td>'.$row['select_type'].'</td>'.
|
||||
'<td>'.$row['table'].'</td>'.
|
||||
'<td>'.$row['partitions'].'</td>'.
|
||||
'<td>'.$row['type'].'</td>'.
|
||||
'<td>'.$row['possible_keys'].'</td>'.
|
||||
'<td>'.$row['key'].'</td>'.
|
||||
'<td>'.$row['key_len'].'</td>'.
|
||||
'<td>'.$row['ref'].'</td>'.
|
||||
'<td>'.$row['rows'].'</td>'.
|
||||
'<td>'.$row['filtered'].'</td>'.
|
||||
'<td>'.$row['Extra'].'</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
echo '</tbody></table>';
|
||||
|
||||
?>
|
||||
</p>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal"><?php echo translate('Close')?> </button>
|
||||
</div>
|
||||
|
||||
@@ -85,3 +85,12 @@ min-width: 500px;
|
||||
clear: both;
|
||||
visibility: hidden;
|
||||
}
|
||||
#filterdebugModal .modal-dialog {
|
||||
width: 80%;
|
||||
max-width: 80%;
|
||||
height: 100%;
|
||||
}
|
||||
#filterdebugModal table th {
|
||||
text-align: left;
|
||||
border-bottom: 1px solid #7f7fb2;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user