Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a page that displays all queries that reference a particular table
- Loading branch information
Showing
4 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,34 @@ | |||
<?php | |||
# | |||
# 'table' UI - search for queries on a given table | |||
# | |||
|
|||
require_once('init.php'); | |||
|
|||
$table = $_GET['table']; | |||
$hours = $_GET['hours']; | |||
|
|||
$q = "SELECT | |||
t.sample as query, sum(h.ts_cnt) as count, t.checksum as checksum | |||
from | |||
{$host_conf['db_query_review_table']} as t | |||
join | |||
{$host_conf['db_query_review_history_table']} as h | |||
on | |||
t.checksum=h.checksum | |||
where | |||
t.sample like '% {$table} %' | |||
AND | |||
h.ts_max > date_sub(now(),interval {$hours} hour) | |||
group by t.checksum order by count desc"; | |||
|
|||
$result=mysql_query($q); | |||
|
|||
$rows = array(); | |||
while ($row = mysql_fetch_assoc($result)) { | |||
$row['explain_url'] = "explain.php?" . ish_build_query(array('checksum'=>$row['checksum'])); | |||
$rows[] = $row; | |||
} | |||
|
|||
require("table.tpl"); | |||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,19 @@ | |||
<?php include("top.tpl"); ?> | |||
<p> | |||
</p> | |||
<h3>More queries on table <?= $_GET['table'] ?></h3> | |||
<table> | |||
<tr> | |||
<th>Count</th> | |||
<th>Query</th> | |||
<th>Explain</th> | |||
</tr> | |||
<? foreach ($rows as $row): ?> | |||
<tr <? if ($counter++ % 2): ?>class="alt"<? endif ?>> | |||
<td><?= $row['count']?></td> | |||
<td><?=format_query($row['query']) ?></td> | |||
<td><a href="<?= $row['explain_url'] ?>">explain</a></td> | |||
</tr> | |||
<? endforeach?> | |||
</table> | |||
<?php include("bottom.tpl"); ?> |