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']); $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 && ($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 "

{$lang['strreferringtables']}

\n"; $columns = array ( 'schema' => array ( 'title' => $lang['strschema'], 'field' => field('nspname') ), 'table' => array ( 'title' => $lang['strtable'], 'field' => field('relname'), ), 'name' => array ( 'title' => $lang['strname'], 'field' => field('conname'), ), 'definition' => array ( 'title' => $lang['strdefinition'], 'field' => field('consrc'), ), 'actions' => array ( 'title' => $lang['stractions'], ) ); $actions = array ( 'properties' => array ( 'content' => $lang['strproperties'], 'attr'=> array ( 'href' => array ( 'url' => 'constraints.php', 'urlvars' => array ( 'schema' => field('nspname'), 'table' => field('relname') ) ) ) ) ); $misc->printTable($referrers, $columns, $actions, 'info-referrers', $lang['strnodata']); } // Parent tables if ($parents->recordCount() > 0) { echo "

{$lang['strparenttables']}

\n"; $columns = array ( 'schema' => array ( 'title' => $lang['strschema'], 'field' => field('nspname') ), 'table' => array ( 'title' => $lang['strtable'], 'field' => field('relname'), ), 'actions' => array ( 'title' => $lang['stractions'], ) ); $actions = array ( 'properties' => array ( 'content' => $lang['strproperties'], 'attr'=> array ( 'href' => array ( 'url' => 'tblproperties.php', 'urlvars' => array ( 'schema' => field('nspname'), 'table' => field('relname') ) ) ) ) ); $misc->printTable($parents, $columns, $actions, 'info-parents', $lang['strnodata']); } // Child tables if ($children->recordCount() > 0) { echo "

{$lang['strchildtables']}

\n"; $columns = array ( 'schema' => array ( 'title' => $lang['strschema'], 'field' => field('nspname') ), 'table' => array ( 'title' => $lang['strtable'], 'field' => field('relname'), ), 'actions' => array ( 'title' => $lang['stractions'], ) ); $actions = array ( 'properties' => array ( 'content' => $lang['strproperties'], 'attr'=> array ( 'href' => array ( 'url' => 'tblproperties.php', 'urlvars' => array ( 'schema' => field('nspname'), 'table' => field('relname') ) ) ) ) ); $misc->printTable($children, $columns, $actions, 'info-children', $lang['strnodata']); } // Row performance if ($tablestatstups->recordCount() > 0) { echo "

{$lang['strrowperf']}

\n"; echo "\n"; echo "\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\n"; echo "\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\n"; $i = 0; while (!$tablestatstups->EOF) { $id = ( ($i % 2 ) == 0 ? '1' : '2' ); echo "\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\n"; $tablestatstups->movenext(); $i++; } echo "
{$lang['strsequential']}{$lang['strindex']}{$lang['strrows2']}
{$lang['strscan']}{$lang['strread']}{$lang['strscan']}{$lang['strfetch']}{$lang['strinsert']}{$lang['strupdate']}{$lang['strdelete']}
", $misc->printVal($tablestatstups->fields['seq_scan'], 'int4', $shownull), "", $misc->printVal($tablestatstups->fields['seq_tup_read'], 'int4', $shownull), "", $misc->printVal($tablestatstups->fields['idx_scan'], 'int4', $shownull), "", $misc->printVal($tablestatstups->fields['idx_tup_fetch'], 'int4', $shownull), "", $misc->printVal($tablestatstups->fields['n_tup_ins'], 'int4', $shownull), "", $misc->printVal($tablestatstups->fields['n_tup_upd'], 'int4', $shownull), "", $misc->printVal($tablestatstups->fields['n_tup_del'], 'int4', $shownull), "
\n"; } // I/O performance if ($tablestatsio->recordCount() > 0) { echo "

{$lang['strioperf']}

\n"; echo "\n"; echo "\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\n"; echo "\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\n"; $i = 0; while (!$tablestatsio->EOF) { $id = ( ($i % 2 ) == 0 ? '1' : '2' ); echo "\t\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\n"; echo "\t\t\n"; echo "\t\t\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\n"; echo "\t\t\n"; echo "\t\t\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\n"; echo "\t\t\n"; echo "\t\t\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\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\n"; $tablestatsio->movenext(); $i++; } echo "
{$lang['strheap']}{$lang['strindex']}{$lang['strtoast']}{$lang['strtoastindex']}
{$lang['strdisk']}{$lang['strcache']}{$lang['strpercent']}{$lang['strdisk']}{$lang['strcache']}{$lang['strpercent']}{$lang['strdisk']}{$lang['strcache']}{$lang['strpercent']}{$lang['strdisk']}{$lang['strcache']}{$lang['strpercent']}
", $misc->printVal($tablestatsio->fields['heap_blks_read'], 'int4', $shownull), "", $misc->printVal($tablestatsio->fields['heap_blks_hit'], 'int4', $shownull), "({$percentage}{$lang['strpercent']})", $misc->printVal($tablestatsio->fields['idx_blks_read'], 'int4', $shownull), "", $misc->printVal($tablestatsio->fields['idx_blks_hit'], 'int4', $shownull), "({$percentage}{$lang['strpercent']})", $misc->printVal($tablestatsio->fields['toast_blks_read'], 'int4', $shownull), "", $misc->printVal($tablestatsio->fields['toast_blks_hit'], 'int4', $shownull), "({$percentage}{$lang['strpercent']})", $misc->printVal($tablestatsio->fields['tidx_blks_read'], 'int4', $shownull), "", $misc->printVal($tablestatsio->fields['tidx_blks_hit'], 'int4', $shownull), "({$percentage}{$lang['strpercent']})
\n"; } // Index row performance if ($indexstatstups->recordCount() > 0) { echo "

{$lang['stridxrowperf']}

\n"; echo "\n"; echo "\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\n"; $i = 0; while (!$indexstatstups->EOF) { $id = ( ($i % 2 ) == 0 ? '1' : '2' ); echo "\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\n"; $indexstatstups->movenext(); $i++; } echo "
{$lang['strindex']}{$lang['strscan']}{$lang['strread']}{$lang['strfetch']}
", $misc->printVal($indexstatstups->fields['indexrelname']), "", $misc->printVal($indexstatstups->fields['idx_scan'], 'int4', $shownull), "", $misc->printVal($indexstatstups->fields['idx_tup_read'], 'int4', $shownull), "", $misc->printVal($indexstatstups->fields['idx_tup_fetch'], 'int4', $shownull), "
\n"; } // Index I/0 performance if ($indexstatsio->recordCount() > 0) { echo "

{$lang['stridxioperf']}

\n"; echo "\n"; echo "\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\n"; $i = 0; while (!$indexstatsio->EOF) { $id = ( ($i % 2 ) == 0 ? '1' : '2' ); echo "\t\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\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\n"; $indexstatsio->movenext(); $i++; } echo "
{$lang['strindex']}{$lang['strdisk']}{$lang['strcache']}{$lang['strpercent']}
", $misc->printVal($indexstatsio->fields['indexrelname']), "", $misc->printVal($indexstatsio->fields['idx_blks_read'], 'int4', $shownull), "", $misc->printVal($indexstatsio->fields['idx_blks_hit'], 'int4', $shownull), "({$percentage}{$lang['strpercent']})
\n"; } } } $misc->printHeader($lang['strtables'] . ' - ' . $_REQUEST['table'] . ' - ' . $lang['strinfo']); $misc->printBody(); switch ($action) { default: doDefault(); break; } $misc->printFooter(); ?>