1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323
|
<?php
/**
* List extra information on a table
*
* $Id: info.php,v 1.14 2007/05/28 17:30:32 ioguix Exp $
*/
// Include application functions
include_once('./libraries/lib.inc.php');
$action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : '';
/**
* List all the information on the table
*/
function doDefault($msg = '') {
global $data, $misc;
global $lang;
$misc->printTrail('table');
$misc->printTabs('table','info');
$misc->printMsg($msg);
// common params for printVal
$shownull = array('null' => true);
// Fetch info
$referrers = $data->getReferrers($_REQUEST['table']);
$parents = $data->getTableParents($_REQUEST['table']);
$children = $data->getTableChildren($_REQUEST['table']);
if ($data->hasStatsCollector()) {
$tablestatstups = $data->getStatsTableTuples($_REQUEST['table']);
$tablestatsio = $data->getStatsTableIO($_REQUEST['table']);
$indexstatstups = $data->getStatsIndexTuples($_REQUEST['table']);
$indexstatsio = $data->getStatsIndexIO($_REQUEST['table']);
}
// Check that there is some info
if (($referrers === -99 || ($referrers !== -99 && $referrers->recordCount() == 0))
&& $parents->recordCount() == 0 && $children->recordCount() == 0
&& (!$data->hasStatsCollector() ||
($tablestatstups->recordCount() == 0 && $tablestatsio->recordCount() == 0
&& $indexstatstups->recordCount() == 0 && $indexstatsio->recordCount() == 0))) {
$misc->printMsg($lang['strnoinfo']);
}
else {
// Referring foreign tables
if ($referrers !== -99 && $referrers->recordCount() > 0) {
echo "<h3>{$lang['strreferringtables']}</h3>\n";
echo "<table>\n";
echo "\t<tr>\n\t\t";
if ($data->hasSchemas()) {
echo "<th class=\"data\">{$lang['strschema']}</th>";
}
echo "<th class=\"data\">{$lang['strtable']}</th>";
echo "<th class=\"data\">{$lang['strname']}</th><th class=\"data\">{$lang['strdefinition']}</th>";
echo "<th class=\"data\">{$lang['stractions']}</th>\n";
echo "\t</tr>\n";
$i = 0;
while (!$referrers->EOF) {
$id = ( ($i % 2 ) == 0 ? '1' : '2' );
echo "\t<tr>\n\t\t";
if ($data->hasSchemas()) {
echo "<td class=\"data{$id}\">", $misc->printVal($referrers->fields['nspname']), "</td>";
}
echo "<td class=\"data{$id}\">", $misc->printVal($referrers->fields['relname']), "</td>";
echo "<td class=\"data{$id}\">", $misc->printVal($referrers->fields['conname']), "</td>";
echo "<td class=\"data{$id}\">", $misc->printVal($referrers->fields['consrc']), "</td>";
echo "<td class=\"opbutton{$id}\"><a href=\"constraints.php?{$misc->href}",
"&schema=", urlencode($referrers->fields['nspname']),
"&table=", urlencode($referrers->fields['relname']), "\">{$lang['strproperties']}</a></td>\n";
echo "\t</tr>\n";
$referrers->movenext();
$i++;
}
echo "</table>\n";
}
// Parent tables
if ($parents->recordCount() > 0) {
echo "<h3>{$lang['strparenttables']}</h3>\n";
echo "<table>\n";
echo "\t<tr>\n\t\t";
if ($data->hasSchemas()) {
echo "<th class=\"data\">{$lang['strschema']}</th>";
}
echo "\t\t<th class=\"data\">{$lang['strtable']}</th>";
echo "<th class=\"data\">{$lang['stractions']}</th>\n";
echo "\t</tr>\n";
$i = 0;
while (!$parents->EOF) {
$id = ( ($i % 2 ) == 0 ? '1' : '2' );
echo "\t<tr>\n";
if ($data->hasSchemas()) {
echo "\t\t<td class=\"data{$id}\">", $misc->printVal($parents->fields['nspname']), "</td>";
}
echo "<td class=\"data{$id}\">", $misc->printVal($parents->fields['relname']), "</td>";
echo "<td class=\"opbutton{$id}\"><a href=\"tblproperties.php?{$misc->href}",
"&schema=", urlencode($parents->fields['nspname']),
"&table=", urlencode($parents->fields['relname']), "\">{$lang['strproperties']}</a></td>\n";
echo "\t</tr>\n";
$parents->movenext();
$i++;
}
echo "</table>\n";
}
// Child tables
if ($children->recordCount() > 0) {
echo "<h3>{$lang['strchildtables']}</h3>\n";
echo "<table>\n";
echo "\t<tr>\n";
if ($data->hasSchemas()) {
echo "<th class=\"data\">{$lang['strschema']}</th>";
}
echo "\t\t<th class=\"data\">{$lang['strtable']}</th>";
echo "<th class=\"data\">{$lang['stractions']}</th>\n";
echo "\t</tr>\n";
$i = 0;
while (!$children->EOF) {
$id = ( ($i % 2 ) == 0 ? '1' : '2' );
echo "\t<tr>\n";
if ($data->hasSchemas()) {
echo "\t\t<td class=\"data{$id}\">", $misc->printVal($children->fields['schemaname']), "</td>";
}
echo "<td class=\"data{$id}\">", $misc->printVal($children->fields['relname']), "</td>";
echo "<td class=\"opbutton{$id}\"><a href=\"tblproperties.php?{$misc->href}",
"&schema=", urlencode($children->fields['schemaname']),
"&table=", urlencode($children->fields['relname']), "\">{$lang['strproperties']}</a></td>\n";
echo "\t</tr>\n";
$children->movenext();
$i++;
}
echo "</table>\n";
}
if ($data->hasStatsCollector()) {
// Row performance
if ($tablestatstups->recordCount() > 0) {
echo "<h3>{$lang['strrowperf']}</h3>\n";
echo "<table>\n";
echo "\t<tr>\n";
echo "\t\t<th class=\"data\" colspan=\"2\">{$lang['strsequential']}</th>\n";
echo "\t\t<th class=\"data\" colspan=\"2\">{$lang['strindex']}</th>\n";
echo "\t\t<th class=\"data\" colspan=\"3\">{$lang['strrows2']}</th>\n";
echo "\t</tr>\n";
echo "\t<tr>\n";
echo "\t\t<th class=\"data\">{$lang['strscan']}</th>\n";
echo "\t\t<th class=\"data\">{$lang['strread']}</th>\n";
echo "\t\t<th class=\"data\">{$lang['strscan']}</th>\n";
echo "\t\t<th class=\"data\">{$lang['strfetch']}</th>\n";
echo "\t\t<th class=\"data\">{$lang['strinsert']}</th>\n";
echo "\t\t<th class=\"data\">{$lang['strupdate']}</th>\n";
echo "\t\t<th class=\"data\">{$lang['strdelete']}</th>\n";
echo "\t</tr>\n";
$i = 0;
while (!$tablestatstups->EOF) {
$id = ( ($i % 2 ) == 0 ? '1' : '2' );
echo "\t<tr>\n";
echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatstups->fields['seq_scan'], 'int4', $shownull), "</td>\n";
echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatstups->fields['seq_tup_read'], 'int4', $shownull), "</td>\n";
echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatstups->fields['idx_scan'], 'int4', $shownull), "</td>\n";
echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatstups->fields['idx_tup_fetch'], 'int4', $shownull), "</td>\n";
echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatstups->fields['n_tup_ins'], 'int4', $shownull), "</td>\n";
echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatstups->fields['n_tup_upd'], 'int4', $shownull), "</td>\n";
echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatstups->fields['n_tup_del'], 'int4', $shownull), "</td>\n";
echo "\t</tr>\n";
$tablestatstups->movenext();
$i++;
}
echo "</table>\n";
}
// I/O performance
if ($tablestatsio->recordCount() > 0) {
echo "<h3>{$lang['strioperf']}</h3>\n";
echo "<table>\n";
echo "\t<tr>\n";
echo "\t\t<th class=\"data\" colspan=\"3\">{$lang['strheap']}</th>\n";
echo "\t\t<th class=\"data\" colspan=\"3\">{$lang['strindex']}</th>\n";
echo "\t\t<th class=\"data\" colspan=\"3\">{$lang['strtoast']}</th>\n";
echo "\t\t<th class=\"data\" colspan=\"3\">{$lang['strtoastindex']}</th>\n";
echo "\t</tr>\n";
echo "\t<tr>\n";
echo "\t\t<th class=\"data\">{$lang['strdisk']}</th>\n";
echo "\t\t<th class=\"data\">{$lang['strcache']}</th>\n";
echo "\t\t<th class=\"data\">{$lang['strpercent']}</th>\n";
echo "\t\t<th class=\"data\">{$lang['strdisk']}</th>\n";
echo "\t\t<th class=\"data\">{$lang['strcache']}</th>\n";
echo "\t\t<th class=\"data\">{$lang['strpercent']}</th>\n";
echo "\t\t<th class=\"data\">{$lang['strdisk']}</th>\n";
echo "\t\t<th class=\"data\">{$lang['strcache']}</th>\n";
echo "\t\t<th class=\"data\">{$lang['strpercent']}</th>\n";
echo "\t\t<th class=\"data\">{$lang['strdisk']}</th>\n";
echo "\t\t<th class=\"data\">{$lang['strcache']}</th>\n";
echo "\t\t<th class=\"data\">{$lang['strpercent']}</th>\n";
echo "\t</tr>\n";
$i = 0;
while (!$tablestatsio->EOF) {
$id = ( ($i % 2 ) == 0 ? '1' : '2' );
echo "\t<tr>\n";
$total = $tablestatsio->fields['heap_blks_hit'] + $tablestatsio->fields['heap_blks_read'];
if ($total > 0) $percentage = round(($tablestatsio->fields['heap_blks_hit'] / $total) * 100);
else $percentage = 0;
echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatsio->fields['heap_blks_read'], 'int4', $shownull), "</td>\n";
echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatsio->fields['heap_blks_hit'], 'int4', $shownull), "</td>\n";
echo "\t\t<td class=\"data{$id}\">({$percentage}{$lang['strpercent']})</td>\n";
$total = $tablestatsio->fields['idx_blks_hit'] + $tablestatsio->fields['idx_blks_read'];
if ($total > 0) $percentage = round(($tablestatsio->fields['idx_blks_hit'] / $total) * 100);
else $percentage = 0;
echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatsio->fields['idx_blks_read'], 'int4', $shownull), "</td>\n";
echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatsio->fields['idx_blks_hit'], 'int4', $shownull), "</td>\n";
echo "\t\t<td class=\"data{$id}\">({$percentage}{$lang['strpercent']})</td>\n";
$total = $tablestatsio->fields['toast_blks_hit'] + $tablestatsio->fields['toast_blks_read'];
if ($total > 0) $percentage = round(($tablestatsio->fields['toast_blks_hit'] / $total) * 100);
else $percentage = 0;
echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatsio->fields['toast_blks_read'], 'int4', $shownull), "</td>\n";
echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatsio->fields['toast_blks_hit'], 'int4', $shownull), "</td>\n";
echo "\t\t<td class=\"data{$id}\">({$percentage}{$lang['strpercent']})</td>\n";
$total = $tablestatsio->fields['tidx_blks_hit'] + $tablestatsio->fields['tidx_blks_read'];
if ($total > 0) $percentage = round(($tablestatsio->fields['tidx_blks_hit'] / $total) * 100);
else $percentage = 0;
echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatsio->fields['tidx_blks_read'], 'int4', $shownull), "</td>\n";
echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatsio->fields['tidx_blks_hit'], 'int4', $shownull), "</td>\n";
echo "\t\t<td class=\"data{$id}\">({$percentage}{$lang['strpercent']})</td>\n";
echo "\t</tr>\n";
$tablestatsio->movenext();
$i++;
}
echo "</table>\n";
}
// Index row performance
if ($indexstatstups->recordCount() > 0) {
echo "<h3>{$lang['stridxrowperf']}</h3>\n";
echo "<table>\n";
echo "\t<tr>\n";
echo "\t\t<th class=\"data\">{$lang['strindex']}</th>\n";
echo "\t\t<th class=\"data\">{$lang['strscan']}</th>\n";
echo "\t\t<th class=\"data\">{$lang['strread']}</th>\n";
echo "\t\t<th class=\"data\">{$lang['strfetch']}</th>\n";
echo "\t</tr>\n";
$i = 0;
while (!$indexstatstups->EOF) {
$id = ( ($i % 2 ) == 0 ? '1' : '2' );
echo "\t<tr>\n";
echo "\t\t<td class=\"data{$id}\">", $misc->printVal($indexstatstups->fields['indexrelname']), "</td>\n";
echo "\t\t<td class=\"data{$id}\">", $misc->printVal($indexstatstups->fields['idx_scan'], 'int4', $shownull), "</td>\n";
echo "\t\t<td class=\"data{$id}\">", $misc->printVal($indexstatstups->fields['idx_tup_read'], 'int4', $shownull), "</td>\n";
echo "\t\t<td class=\"data{$id}\">", $misc->printVal($indexstatstups->fields['idx_tup_fetch'], 'int4', $shownull), "</td>\n";
echo "\t</tr>\n";
$indexstatstups->movenext();
$i++;
}
echo "</table>\n";
}
// Index I/0 performance
if ($indexstatsio->recordCount() > 0) {
echo "<h3>{$lang['stridxioperf']}</h3>\n";
echo "<table>\n";
echo "\t<tr>\n";
echo "\t\t<th class=\"data\">{$lang['strindex']}</th>\n";
echo "\t\t<th class=\"data\">{$lang['strdisk']}</th>\n";
echo "\t\t<th class=\"data\">{$lang['strcache']}</th>\n";
echo "\t\t<th class=\"data\">{$lang['strpercent']}</th>\n";
echo "\t</tr>\n";
$i = 0;
while (!$indexstatsio->EOF) {
$id = ( ($i % 2 ) == 0 ? '1' : '2' );
echo "\t<tr>\n";
$total = $indexstatsio->fields['idx_blks_hit'] + $indexstatsio->fields['idx_blks_read'];
if ($total > 0) $percentage = round(($indexstatsio->fields['idx_blks_hit'] / $total) * 100);
else $percentage = 0;
echo "\t\t<td class=\"data{$id}\">", $misc->printVal($indexstatsio->fields['indexrelname']), "</td>\n";
echo "\t\t<td class=\"data{$id}\">", $misc->printVal($indexstatsio->fields['idx_blks_read'], 'int4', $shownull), "</td>\n";
echo "\t\t<td class=\"data{$id}\">", $misc->printVal($indexstatsio->fields['idx_blks_hit'], 'int4', $shownull), "</td>\n";
echo "\t\t<td class=\"data{$id}\">({$percentage}{$lang['strpercent']})</td>\n";
echo "\t</tr>\n";
$indexstatsio->movenext();
$i++;
}
echo "</table>\n";
}
}
}
}
$misc->printHeader($lang['strtables'] . ' - ' . $_REQUEST['table'] . ' - ' . $lang['strinfo']);
$misc->printBody();
switch ($action) {
default:
doDefault();
break;
}
$misc->printFooter();
?>
|