improve efficiency of devices/ports/, add some caching, fix db profiling.

git-svn-id: http://www.observium.org/svn/observer/trunk@2349 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2011-05-19 10:02:55 +00:00
parent 2978386af4
commit bf1d43ae65
6 changed files with 67 additions and 16 deletions

View File

@@ -88,7 +88,20 @@ if ($_GET['optc'] == thumbs)
if ($_GET['opta'] == "details") { $port_details = 1; }
echo("<div style='margin: 0px;'><table border=0 cellspacing=0 cellpadding=5 width=100%>");
$i = "1";
foreach (dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = '0' ORDER BY `ifIndex` ASC", array($device['device_id'])) as $interface)
global $port_cache;
global $port_index_cache;
$ports = dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = '0' ORDER BY `ifIndex` ASC", array($device['device_id']));
### As we've dragged the whole database, lets pre-populate our caches :)
### FIXME - we should probably split the fetching of link/stack/etc into functions and cache them here too to cut down on single row queries.
foreach($ports as $port)
{
$port_cache[$port['interface_id']] = $port;
$port_index_cache[$port['device_id']][$port['ifIndex']] = $port;
}
foreach ($ports as $interface)
{
include("includes/print-interface.inc.php");
$i++;