logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

mantisbt/core/adodb/perf perf-db2.inc.php,1.1,1.2 perf-informix.inc.php,1.1: msg#00048

Subject: mantisbt/core/adodb/perf perf-db2.inc.php,1.1,1.2 perf-informix.inc.php,1.1,1.2 perf-mssql.inc.php,1.1,1.2 perf-mysql.inc.php,1.1,1.2 perf-oci8.inc.php,1.1,1.2 perf-postgres.inc.php,1.1,1.2
Update of /cvsroot/mantisbt/mantisbt/core/adodb/perf
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23600/perf

Modified Files:
        perf-db2.inc.php perf-informix.inc.php perf-mssql.inc.php 
        perf-mysql.inc.php perf-oci8.inc.php perf-postgres.inc.php 
Log Message:
updating adodb to v4.60 (#5171)


Index: perf-postgres.inc.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/adodb/perf/perf-postgres.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- perf-postgres.inc.php       29 Nov 2004 23:16:59 -0000      1.1
+++ perf-postgres.inc.php       27 Jan 2005 14:43:46 -0000      1.2
@@ -1,123 +1,123 @@
-<?php
-
-/* 
-V4.54 5 Nov 2004  (c) 2000-2004 John Lim 
(jlim-l15XFKl8ZeYZ+IcD6AW/HA@xxxxxxxxxxxxxxxx). All rights reserved.
-  Released under both BSD license and Lesser GPL library license. 
-  Whenever there is any discrepancy between the two licenses, 
-  the BSD license will take precedence. See License.txt. 
-  Set tabs to 4 for best viewing.
-  
-  Latest version is available at http://adodb.sourceforge.net
-  
-  Library for basic performance monitoring and tuning 
-  
-*/
-
-// security - hide paths
-if (!defined('ADODB_DIR')) die();
-
-/*
-       Notice that PostgreSQL has no sql query cache
-*/
-class perf_postgres extends adodb_perf{
-       
-       var $tablesSQL = 
-       "select a.relname as tablename,(a.relpages+CASE WHEN b.relpages is null 
THEN 0 ELSE b.relpages END+CASE WHEN c.relpages is null THEN 0 ELSE c.relpages 
END)*8 as size_in_K,a.relfilenode as \"OID\"  from pg_class a left join 
pg_class b
-               on b.relname = 'pg_toast_'||trim(a.relfilenode) 
-               left join pg_class c on c.relname = 
'pg_toast_'||trim(a.relfilenode)||'_index'
-               where a.relname in (select tablename from pg_tables where 
tablename not like 'pg_%')";
-       
-       var $createTableSQL = "CREATE TABLE adodb_logsql (
-                 created timestamp NOT NULL,
-                 sql0 varchar(250) NOT NULL,
-                 sql1 text NOT NULL,
-                 params text NOT NULL,
-                 tracer text NOT NULL,
-                 timer decimal(16,6) NOT NULL
-               )";     
-       
-       var $settings = array(
-       'Ratios',
-               'statistics collector' => array('RATIO',
-                       "select case when count(*)=3 then 'TRUE' else 'FALSE' 
end from pg_settings where (name='stats_block_level' or name='stats_row_level' 
or name='stats_start_collector') and setting='on' ",
-                       'Value must be TRUE to enable hit ratio statistics 
(<i>stats_start_collector</i>,<i>stats_row_level</i> and 
<i>stats_block_level</i> must be set to true in postgresql.conf)'),
-               'data cache hit ratio' => array('RATIO',
-                       "select case when blks_hit=0 then 0 else 
(1-blks_read::float/blks_hit)*100 end from pg_stat_database where 
datname='\$DATABASE'",
-                       '=WarnCacheRatio'),
-       'IO',
-               'data reads' => array('IO',
-               'select sum(heap_blks_read+toast_blks_read) from 
pg_statio_user_tables',
-               ),
-               'data writes' => array('IO',
-               'select sum(n_tup_ins/4.0+n_tup_upd/8.0+n_tup_del/4.0)/16 from 
pg_stat_user_tables',
-               'Count of inserts/updates/deletes * coef'),
-
-       'Data Cache',
-               'data cache buffers' => array('DATAC',
-                       "select setting from pg_settings where 
name='shared_buffers'",
-                       'Number of cache buffers. <a 
href=http://www.varlena.com/GeneralBits/Tidbits/perf.html#basic>Tuning</a>'),
-               'cache blocksize' => array('DATAC',
-                       'select 8192',
-                       '(estimate)' ),
-               'data cache size' => array( 'DATAC',
-               "select setting::integer*8192 from pg_settings where 
name='shared_buffers'",
-                       '' ),
-               'operating system cache size' => array( 'DATA',
-               "select setting::integer*8192 from pg_settings where 
name='effective_cache_size'",
-                       '(effective cache size)' ),
-       'Memory Usage',
-               'sort buffer size' => array('CACHE',
-                       "select setting::integer*1024 from pg_settings where 
name='sort_mem'",
-                       'Size of sort buffer (per query)' ),
-       'Connections',
-               'current connections' => array('SESS',
-                       'select count(*) from pg_stat_activity',
-                       ''),
-               'max connections' => array('SESS',
-                       "select setting from pg_settings where 
name='max_connections'",
-                       ''),
-       'Parameters',
-               'rollback buffers' => array('COST',
-                       "select setting from pg_settings where 
name='wal_buffers'",
-                       'WAL buffers'),
-               'random page cost' => array('COST',
-                       "select setting from pg_settings where 
name='random_page_cost'",
-                       'Cost of doing a seek (default=4). See <a 
href=http://www.varlena.com/GeneralBits/Tidbits/perf.html#less>random_page_cost</a>'),
-               false
-       );
-       
-       function perf_postgres(&$conn)
-       {
-               $this->conn =& $conn;
-       }
-       
-       function Explain($sql,$partial=false)
-       {
-               $save = $this->conn->LogSQL(false);
-               
-               if ($partial) {
-                       $sqlq = $this->conn->qstr($sql.'%');
-                       $arr = $this->conn->GetArray("select distinct distinct 
sql1 from adodb_logsql where sql1 like $sqlq");
-                       if ($arr) {
-                               foreach($arr as $row) {
-                                       $sql = reset($row);
-                                       if (crc32($sql) == $partial) break;
-                               }
-                       }
-               }
-               $sql = str_replace('?',"''",$sql);
-               $s = '<p><b>Explain</b>: '.htmlspecialchars($sql).'</p>';
-               $rs = $this->conn->Execute('EXPLAIN '.$sql);
-               $this->conn->LogSQL($save);
-               $s .= '<pre>';
-               if ($rs)
-                       while (!$rs->EOF) {
-                               $s .= reset($rs->fields)."\n";
-                               $rs->MoveNext();
-                       }
-               $s .= '</pre>';
-               $s .= $this->Tracer($sql,$partial);
-               return $s;
-       }
-}
+<?php
+
+/* 
+V4.60 24 Jan 2005  (c) 2000-2005 John Lim 
(jlim-l15XFKl8ZeYZ+IcD6AW/HA@xxxxxxxxxxxxxxxx). All rights reserved.
+  Released under both BSD license and Lesser GPL library license. 
+  Whenever there is any discrepancy between the two licenses, 
+  the BSD license will take precedence. See License.txt. 
+  Set tabs to 4 for best viewing.
+  
+  Latest version is available at http://adodb.sourceforge.net
+  
+  Library for basic performance monitoring and tuning 
+  
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+/*
+       Notice that PostgreSQL has no sql query cache
+*/
+class perf_postgres extends adodb_perf{
+       
+       var $tablesSQL = 
+       "select a.relname as tablename,(a.relpages+CASE WHEN b.relpages is null 
THEN 0 ELSE b.relpages END+CASE WHEN c.relpages is null THEN 0 ELSE c.relpages 
END)*8 as size_in_K,a.relfilenode as \"OID\"  from pg_class a left join 
pg_class b
+               on b.relname = 'pg_toast_'||trim(a.relfilenode) 
+               left join pg_class c on c.relname = 
'pg_toast_'||trim(a.relfilenode)||'_index'
+               where a.relname in (select tablename from pg_tables where 
tablename not like 'pg_%')";
+       
+       var $createTableSQL = "CREATE TABLE adodb_logsql (
+                 created timestamp NOT NULL,
+                 sql0 varchar(250) NOT NULL,
+                 sql1 text NOT NULL,
+                 params text NOT NULL,
+                 tracer text NOT NULL,
+                 timer decimal(16,6) NOT NULL
+               )";     
+       
+       var $settings = array(
+       'Ratios',
+               'statistics collector' => array('RATIO',
+                       "select case when count(*)=3 then 'TRUE' else 'FALSE' 
end from pg_settings where (name='stats_block_level' or name='stats_row_level' 
or name='stats_start_collector') and setting='on' ",
+                       'Value must be TRUE to enable hit ratio statistics 
(<i>stats_start_collector</i>,<i>stats_row_level</i> and 
<i>stats_block_level</i> must be set to true in postgresql.conf)'),
+               'data cache hit ratio' => array('RATIO',
+                       "select case when blks_hit=0 then 0 else 
(1-blks_read::float/blks_hit)*100 end from pg_stat_database where 
datname='\$DATABASE'",
+                       '=WarnCacheRatio'),
+       'IO',
+               'data reads' => array('IO',
+               'select sum(heap_blks_read+toast_blks_read) from 
pg_statio_user_tables',
+               ),
+               'data writes' => array('IO',
+               'select sum(n_tup_ins/4.0+n_tup_upd/8.0+n_tup_del/4.0)/16 from 
pg_stat_user_tables',
+               'Count of inserts/updates/deletes * coef'),
+
+       'Data Cache',
+               'data cache buffers' => array('DATAC',
+                       "select setting from pg_settings where 
name='shared_buffers'",
+                       'Number of cache buffers. <a 
href=http://www.varlena.com/GeneralBits/Tidbits/perf.html#basic>Tuning</a>'),
+               'cache blocksize' => array('DATAC',
+                       'select 8192',
+                       '(estimate)' ),
+               'data cache size' => array( 'DATAC',
+               "select setting::integer*8192 from pg_settings where 
name='shared_buffers'",
+                       '' ),
+               'operating system cache size' => array( 'DATA',
+               "select setting::integer*8192 from pg_settings where 
name='effective_cache_size'",
+                       '(effective cache size)' ),
+       'Memory Usage',
+               'sort buffer size' => array('CACHE',
+                       "select setting::integer*1024 from pg_settings where 
name='sort_mem'",
+                       'Size of sort buffer (per query)' ),
+       'Connections',
+               'current connections' => array('SESS',
+                       'select count(*) from pg_stat_activity',
+                       ''),
+               'max connections' => array('SESS',
+                       "select setting from pg_settings where 
name='max_connections'",
+                       ''),
+       'Parameters',
+               'rollback buffers' => array('COST',
+                       "select setting from pg_settings where 
name='wal_buffers'",
+                       'WAL buffers'),
+               'random page cost' => array('COST',
+                       "select setting from pg_settings where 
name='random_page_cost'",
+                       'Cost of doing a seek (default=4). See <a 
href=http://www.varlena.com/GeneralBits/Tidbits/perf.html#less>random_page_cost</a>'),
+               false
+       );
+       
+       function perf_postgres(&$conn)
+       {
+               $this->conn =& $conn;
+       }
+       
+       function Explain($sql,$partial=false)
+       {
+               $save = $this->conn->LogSQL(false);
+               
+               if ($partial) {
+                       $sqlq = $this->conn->qstr($sql.'%');
+                       $arr = $this->conn->GetArray("select distinct distinct 
sql1 from adodb_logsql where sql1 like $sqlq");
+                       if ($arr) {
+                               foreach($arr as $row) {
+                                       $sql = reset($row);
+                                       if (crc32($sql) == $partial) break;
+                               }
+                       }
+               }
+               $sql = str_replace('?',"''",$sql);
+               $s = '<p><b>Explain</b>: '.htmlspecialchars($sql).'</p>';
+               $rs = $this->conn->Execute('EXPLAIN '.$sql);
+               $this->conn->LogSQL($save);
+               $s .= '<pre>';
+               if ($rs)
+                       while (!$rs->EOF) {
+                               $s .= reset($rs->fields)."\n";
+                               $rs->MoveNext();
+                       }
+               $s .= '</pre>';
+               $s .= $this->Tracer($sql,$partial);
+               return $s;
+       }
+}
 ?>
\ No newline at end of file

Index: perf-mssql.inc.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/adodb/perf/perf-mssql.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- perf-mssql.inc.php  29 Nov 2004 23:16:59 -0000      1.1
+++ perf-mssql.inc.php  27 Jan 2005 14:43:45 -0000      1.2
@@ -1,164 +1,164 @@
-<?php
-
-/* 
-V4.54 5 Nov 2004  (c) 2000-2004 John Lim 
(jlim-l15XFKl8ZeYZ+IcD6AW/HA@xxxxxxxxxxxxxxxx). All rights reserved.
-  Released under both BSD license and Lesser GPL library license. 
-  Whenever there is any discrepancy between the two licenses, 
-  the BSD license will take precedence. See License.txt. 
-  Set tabs to 4 for best viewing.
-  
-  Latest version is available at http://adodb.sourceforge.net
-  
-  Library for basic performance monitoring and tuning 
-  
-*/
-
-// security - hide paths
-if (!defined('ADODB_DIR')) die();
-
-/*
-       MSSQL has moved most performance info to Performance Monitor
-*/
-class perf_mssql extends adodb_perf{
-       var $sql1 = 'cast(sql1 as text)';
-       var $createTableSQL = "CREATE TABLE adodb_logsql (
-                 created datetime NOT NULL,
-                 sql0 varchar(250) NOT NULL,
-                 sql1 varchar(4000) NOT NULL,
-                 params varchar(3000) NOT NULL,
-                 tracer varchar(500) NOT NULL,
-                 timer decimal(16,6) NOT NULL
-               )";
-               
-       var $settings = array(
-       'Ratios',
-               'data cache hit ratio' => array('RATIO',
-                       "select round((a.cntr_value*100.0)/b.cntr_value,2) from 
master.dbo.sysperfinfo a, master.dbo.sysperfinfo b where a.counter_name = 
'Buffer cache hit ratio' and b.counter_name='Buffer cache hit ratio base'",
-                       '=WarnCacheRatio'),
-               'prepared sql hit ratio' => array('RATIO',
-                       array('dbcc cachestats','Prepared',1,100),
-                       ''),
-               'adhoc sql hit ratio' => array('RATIO',
-                       array('dbcc cachestats','Adhoc',1,100),
-                       ''),
-       'IO',
-               'data reads' => array('IO',
-               "select cntr_value from master.dbo.sysperfinfo where 
counter_name = 'Page reads/sec'"),
-               'data writes' => array('IO',
-               "select cntr_value from master.dbo.sysperfinfo where 
counter_name = 'Page writes/sec'"),
-                       
-       'Data Cache',
-               'data cache size' => array('DATAC',
-               "select cntr_value*8192 from master.dbo.sysperfinfo where 
counter_name = 'Total Pages' and object_name='SQLServer:Buffer Manager'",
-                       '' ),
-               'data cache blocksize' => array('DATAC',
-                       "select 8192",'page size'),
-       'Connections',
-               'current connections' => array('SESS',
-                       '=sp_who',
-                       ''),
-               'max connections' => array('SESS',
-                       "SELECT @@MAX_CONNECTIONS",
-                       ''),
-
-               false
-       );
-       
-       
-       function perf_mssql(&$conn)
-       {
-               if ($conn->dataProvider == 'odbc') {
-                       $this->sql1 = 'sql1';
-                       //$this->explain = false;
-               }
-               $this->conn =& $conn;
-       }
-       
-       function Explain($sql,$partial=false)
-       {
-               
-               $save = $this->conn->LogSQL(false);
-               if ($partial) {
-                       $sqlq = $this->conn->qstr($sql.'%');
-                       $arr = $this->conn->GetArray("select distinct sql1 from 
adodb_logsql where sql1 like $sqlq");
-                       if ($arr) {
-                               foreach($arr as $row) {
-                                       $sql = reset($row);
-                                       if (crc32($sql) == $partial) break;
-                               }
-                       }
-               }
-               
-               $s = '<p><b>Explain</b>: '.htmlspecialchars($sql).'</p>';
-               $this->conn->Execute("SET SHOWPLAN_ALL ON;");
-               $sql = str_replace('?',"''",$sql);
-               global $ADODB_FETCH_MODE;
-               
-               $save = $ADODB_FETCH_MODE;
-               $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
-               $rs =& $this->conn->Execute($sql);
-               //adodb_printr($rs);
-               $ADODB_FETCH_MODE = $save;
-               if ($rs) {
-                       $rs->MoveNext();
-                       $s .= '<table bgcolor=white border=0 cellpadding="1" 
callspacing=0><tr><td nowrap align=center> Rows<td nowrap align=center> IO<td 
nowrap align=center> CPU<td align=left> &nbsp; &nbsp; Plan</tr>';
-                       while (!$rs->EOF) {
-                               $s .= 
'<tr><td>'.round($rs->fields[8],1).'<td>'.round($rs->fields[9],3).'<td 
align=right>'.round($rs->fields[10],3).'<td 
nowrap><pre>'.htmlspecialchars($rs->fields[0])."</td></pre></tr>\n"; ## NOTE 
CORRUPT </td></pre> tag is intentional!!!!
-                               $rs->MoveNext();
-                       }
-                       $s .= '</table>';
-                       
-                       $rs->NextRecordSet();
-               }
-               
-               $this->conn->Execute("SET SHOWPLAN_ALL OFF;");
-               $this->conn->LogSQL($save);
-               $s .= $this->Tracer($sql);
-               return $s;
-       }
-       
-       function Tables()
-       {
-       global $ADODB_FETCH_MODE;
-       
-               $save = $ADODB_FETCH_MODE;
-               $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
-               //$this->conn->debug=1;
-               $s = '<table border=1 
bgcolor=white><tr><td><b>tablename</b></td><td><b>size_in_k</b></td><td><b>index
 size</b></td><td><b>reserved size</b></td></tr>';
-               $rs1 = $this->conn->Execute("select distinct name from 
sysobjects where xtype='U'");
-               if ($rs1) {
-                       while (!$rs1->EOF) {
-                               $tab = $rs1->fields[0];
-                               $tabq = $this->conn->qstr($tab);
-                               $rs2 = $this->conn->Execute("sp_spaceused 
$tabq");
-                               if ($rs2) {
-                                       $s .= '<tr><td>'.$tab.'</td><td 
align=right>'.$rs2->fields[3].'</td><td align=right>'.$rs2->fields[4].'</td><td 
align=right>'.$rs2->fields[2].'</td></tr>';
-                                       $rs2->Close();
-                               }
-                               $rs1->MoveNext();
-                       }
-                       $rs1->Close();
-               }
-               $ADODB_FETCH_MODE = $save;
-               return $s.'</table>';
-       }
-       
-       function sp_who()
-       {
-               $arr = $this->conn->GetArray('sp_who');
-               return sizeof($arr);
-       }
-       
-       function HealthCheck($cli=false)
-       {
-               
-               $this->conn->Execute('dbcc traceon(3604)');
-               $html =  adodb_perf::HealthCheck($cli);
-               $this->conn->Execute('dbcc traceoff(3604)');
-               return $html;
-       }
-       
-       
-}
-
+<?php
+
+/* 
+V4.60 24 Jan 2005  (c) 2000-2005 John Lim 
(jlim-l15XFKl8ZeYZ+IcD6AW/HA@xxxxxxxxxxxxxxxx). All rights reserved.
+  Released under both BSD license and Lesser GPL library license. 
+  Whenever there is any discrepancy between the two licenses, 
+  the BSD license will take precedence. See License.txt. 
+  Set tabs to 4 for best viewing.
+  
+  Latest version is available at http://adodb.sourceforge.net
+  
+  Library for basic performance monitoring and tuning 
+  
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+/*
+       MSSQL has moved most performance info to Performance Monitor
+*/
+class perf_mssql extends adodb_perf{
+       var $sql1 = 'cast(sql1 as text)';
+       var $createTableSQL = "CREATE TABLE adodb_logsql (
+                 created datetime NOT NULL,
+                 sql0 varchar(250) NOT NULL,
+                 sql1 varchar(4000) NOT NULL,
+                 params varchar(3000) NOT NULL,
+                 tracer varchar(500) NOT NULL,
+                 timer decimal(16,6) NOT NULL
+               )";
+               
+       var $settings = array(
+       'Ratios',
+               'data cache hit ratio' => array('RATIO',
+                       "select round((a.cntr_value*100.0)/b.cntr_value,2) from 
master.dbo.sysperfinfo a, master.dbo.sysperfinfo b where a.counter_name = 
'Buffer cache hit ratio' and b.counter_name='Buffer cache hit ratio base'",
+                       '=WarnCacheRatio'),
+               'prepared sql hit ratio' => array('RATIO',
+                       array('dbcc cachestats','Prepared',1,100),
+                       ''),
+               'adhoc sql hit ratio' => array('RATIO',
+                       array('dbcc cachestats','Adhoc',1,100),
+                       ''),
+       'IO',
+               'data reads' => array('IO',
+               "select cntr_value from master.dbo.sysperfinfo where 
counter_name = 'Page reads/sec'"),
+               'data writes' => array('IO',
+               "select cntr_value from master.dbo.sysperfinfo where 
counter_name = 'Page writes/sec'"),
+                       
+       'Data Cache',
+               'data cache size' => array('DATAC',
+               "select cntr_value*8192 from master.dbo.sysperfinfo where 
counter_name = 'Total Pages' and object_name='SQLServer:Buffer Manager'",
+                       '' ),
+               'data cache blocksize' => array('DATAC',
+                       "select 8192",'page size'),
+       'Connections',
+               'current connections' => array('SESS',
+                       '=sp_who',
+                       ''),
+               'max connections' => array('SESS',
+                       "SELECT @@MAX_CONNECTIONS",
+                       ''),
+
+               false
+       );
+       
+       
+       function perf_mssql(&$conn)
+       {
+               if ($conn->dataProvider == 'odbc') {
+                       $this->sql1 = 'sql1';
+                       //$this->explain = false;
+               }
+               $this->conn =& $conn;
+       }
+       
+       function Explain($sql,$partial=false)
+       {
+               
+               $save = $this->conn->LogSQL(false);
+               if ($partial) {
+                       $sqlq = $this->conn->qstr($sql.'%');
+                       $arr = $this->conn->GetArray("select distinct sql1 from 
adodb_logsql where sql1 like $sqlq");
+                       if ($arr) {
+                               foreach($arr as $row) {
+                                       $sql = reset($row);
+                                       if (crc32($sql) == $partial) break;
+                               }
+                       }
+               }
+               
+               $s = '<p><b>Explain</b>: '.htmlspecialchars($sql).'</p>';
+               $this->conn->Execute("SET SHOWPLAN_ALL ON;");
+               $sql = str_replace('?',"''",$sql);
+               global $ADODB_FETCH_MODE;
+               
+               $save = $ADODB_FETCH_MODE;
+               $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+               $rs =& $this->conn->Execute($sql);
+               //adodb_printr($rs);
+               $ADODB_FETCH_MODE = $save;
+               if ($rs) {
+                       $rs->MoveNext();
+                       $s .= '<table bgcolor=white border=0 cellpadding="1" 
callspacing=0><tr><td nowrap align=center> Rows<td nowrap align=center> IO<td 
nowrap align=center> CPU<td align=left> &nbsp; &nbsp; Plan</tr>';
+                       while (!$rs->EOF) {
+                               $s .= 
'<tr><td>'.round($rs->fields[8],1).'<td>'.round($rs->fields[9],3).'<td 
align=right>'.round($rs->fields[10],3).'<td 
nowrap><pre>'.htmlspecialchars($rs->fields[0])."</td></pre></tr>\n"; ## NOTE 
CORRUPT </td></pre> tag is intentional!!!!
+                               $rs->MoveNext();
+                       }
+                       $s .= '</table>';
+                       
+                       $rs->NextRecordSet();
+               }
+               
+               $this->conn->Execute("SET SHOWPLAN_ALL OFF;");
+               $this->conn->LogSQL($save);
+               $s .= $this->Tracer($sql);
+               return $s;
+       }
+       
+       function Tables()
+       {
+       global $ADODB_FETCH_MODE;
+       
+               $save = $ADODB_FETCH_MODE;
+               $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+               //$this->conn->debug=1;
+               $s = '<table border=1 
bgcolor=white><tr><td><b>tablename</b></td><td><b>size_in_k</b></td><td><b>index
 size</b></td><td><b>reserved size</b></td></tr>';
+               $rs1 = $this->conn->Execute("select distinct name from 
sysobjects where xtype='U'");
+               if ($rs1) {
+                       while (!$rs1->EOF) {
+                               $tab = $rs1->fields[0];
+                               $tabq = $this->conn->qstr($tab);
+                               $rs2 = $this->conn->Execute("sp_spaceused 
$tabq");
+                               if ($rs2) {
+                                       $s .= '<tr><td>'.$tab.'</td><td 
align=right>'.$rs2->fields[3].'</td><td align=right>'.$rs2->fields[4].'</td><td 
align=right>'.$rs2->fields[2].'</td></tr>';
+                                       $rs2->Close();
+                               }
+                               $rs1->MoveNext();
+                       }
+                       $rs1->Close();
+               }
+               $ADODB_FETCH_MODE = $save;
+               return $s.'</table>';
+       }
+       
+       function sp_who()
+       {
+               $arr = $this->conn->GetArray('sp_who');
+               return sizeof($arr);
+       }
+       
+       function HealthCheck($cli=false)
+       {
+               
+               $this->conn->Execute('dbcc traceon(3604)');
+               $html =  adodb_perf::HealthCheck($cli);
+               $this->conn->Execute('dbcc traceoff(3604)');
+               return $html;
+       }
+       
+       
+}
+
 ?>
\ No newline at end of file

Index: perf-oci8.inc.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/adodb/perf/perf-oci8.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- perf-oci8.inc.php   29 Nov 2004 23:16:59 -0000      1.1
+++ perf-oci8.inc.php   27 Jan 2005 14:43:46 -0000      1.2
@@ -1,499 +1,499 @@
-<?php
-/* 
-V4.54 5 Nov 2004  (c) 2000-2004 John Lim 
(jlim-l15XFKl8ZeYZ+IcD6AW/HA@xxxxxxxxxxxxxxxx). All rights reserved.
-  Released under both BSD license and Lesser GPL library license. 
-  Whenever there is any discrepancy between the two licenses, 
-  the BSD license will take precedence. See License.txt. 
-  Set tabs to 4 for best viewing.
-  
-  Latest version is available at http://adodb.sourceforge.net
-  
-  Library for basic performance monitoring and tuning 
[...967 lines suppressed...]
+               $ADODB_CACHE_MODE = ADODB_FETCH_NUM;
+               $savelog = $this->conn->LogSQL(false);
+               $rs =& $this->conn->Execute($sql);
+               $this->conn->LogSQL($savelog);
+               $ADODB_CACHE_MODE = $save;
+               if ($rs) {
+                       $s = "\n<h3>Ixora Expensive SQL</h3>";
+                       $s .= $this->tohtml($rs,'expeixora');
+               } else 
+                       $s = '';
+               
+               
+               if ($s) $s .= '<p>';
+               $s .= $this->_ExpensiveSQL();
+               return $s;
+       }
+       
+}
 ?>
\ No newline at end of file

Index: perf-db2.inc.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/adodb/perf/perf-db2.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- perf-db2.inc.php    29 Nov 2004 23:16:59 -0000      1.1
+++ perf-db2.inc.php    27 Jan 2005 14:43:45 -0000      1.2
@@ -1,102 +1,102 @@
-<?php
-/* 
-V4.54 5 Nov 2004  (c) 2000-2004 John Lim 
(jlim-l15XFKl8ZeYZ+IcD6AW/HA@xxxxxxxxxxxxxxxx). All rights reserved.
-  Released under both BSD license and Lesser GPL library license. 
-  Whenever there is any discrepancy between the two licenses, 
-  the BSD license will take precedence. See License.txt. 
-  Set tabs to 4 for best viewing.
-  
-  Latest version is available at http://adodb.sourceforge.net
-  
-  Library for basic performance monitoring and tuning 
-  
-*/
-
-// security - hide paths
-if (!defined('ADODB_DIR')) die();
-
-// Simple guide to configuring db2: so-so 
http://www.devx.com/gethelpon/10MinuteSolution/16575
-
-// SELECT * FROM TABLE(SNAPSHOT_APPL('SAMPLE', -1)) as t
-class perf_db2 extends adodb_perf{
-       var $createTableSQL = "CREATE TABLE adodb_logsql (
-                 created TIMESTAMP NOT NULL,
-                 sql0 varchar(250) NOT NULL,
-                 sql1 varchar(4000) NOT NULL,
-                 params varchar(3000) NOT NULL,
-                 tracer varchar(500) NOT NULL,
-                 timer decimal(16,6) NOT NULL
-               )";
-               
-       var $settings = array(
-       'Ratios',
-               'data cache hit ratio' => array('RATIO',
-                       "SELECT 
-                               case when 
sum(POOL_DATA_L_READS+POOL_INDEX_L_READS)=0 then 0 
-                               else 
100*(1-sum(POOL_DATA_P_READS+POOL_INDEX_P_READS)/sum(POOL_DATA_L_READS+POOL_INDEX_L_READS))
 end 
-                               FROM TABLE(SNAPSHOT_APPL('',-2)) as t",
-                       '=WarnCacheRatio'),
-                       
-       'Data Cache',
-               'data cache buffers' => array('DATAC',
-               'select sum(npages) from SYSCAT.BUFFERPOOLS',
-                       'See <a 
href=http://www7b.boulder.ibm.com/dmdd/library/techarticle/anshum/0107anshum.html#bufferpoolsize>tuning
 reference</a>.' ),
-               'cache blocksize' => array('DATAC',
-               'select avg(pagesize) from SYSCAT.BUFFERPOOLS',
-                       '' ),
-               'data cache size' => array('DATAC',
-               'select sum(npages*pagesize) from SYSCAT.BUFFERPOOLS',
-                       '' ),
-       'Connections',
-               'current connections' => array('SESS',
-                       "SELECT count(*) FROM TABLE(SNAPSHOT_APPL_INFO('',-2)) 
as t",
-                       ''),
-
-               false
-       );
-
-
-       function perf_db2(&$conn)
-       {
-               $this->conn =& $conn;
-       }
-       
-       function Explain($sql,$partial=false)
-       {
-               $save = $this->conn->LogSQL(false);
-               if ($partial) {
-                       $sqlq = $this->conn->qstr($sql.'%');
-                       $arr = $this->conn->GetArray("select distinct sql1 from 
adodb_logsql where sql1 like $sqlq");
-                       if ($arr) {
-                               foreach($arr as $row) {
-                                       $sql = reset($row);
-                                       if (crc32($sql) == $partial) break;
-                               }
-                       }
-               }
-               $qno = rand();
-               $ok = $this->conn->Execute("EXPLAIN PLAN SET QUERYNO=$qno FOR 
$sql");
-               ob_start();
-               if (!$ok) echo "<p>Have EXPLAIN tables been created?</p>";
-               else {
-                       $rs = $this->conn->Execute("select * from 
explain_statement where queryno=$qno");
-                       if ($rs) rs2html($rs);
-               }
-               $s = ob_get_contents();
-               ob_end_clean();
-               $this->conn->LogSQL($save);
-               
-               $s .= $this->Tracer($sql);
-               return $s;
-       }
-       
-       
-       function Tables()
-       {
-               $rs = $this->conn->Execute("select tabschema,tabname,card as 
rows,
-                       npages pages_used,fpages pages_allocated, tbspace 
tablespace  
-                       from syscat.tables where tabschema not in 
('SYSCAT','SYSIBM','SYSSTAT') order by 1,2");
-               return rs2html($rs,false,false,false,false);
-       }
-}
+<?php
+/* 
+V4.60 24 Jan 2005  (c) 2000-2005 John Lim 
(jlim-l15XFKl8ZeYZ+IcD6AW/HA@xxxxxxxxxxxxxxxx). All rights reserved.
+  Released under both BSD license and Lesser GPL library license. 
+  Whenever there is any discrepancy between the two licenses, 
+  the BSD license will take precedence. See License.txt. 
+  Set tabs to 4 for best viewing.
+  
+  Latest version is available at http://adodb.sourceforge.net
+  
+  Library for basic performance monitoring and tuning 
+  
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+// Simple guide to configuring db2: so-so 
http://www.devx.com/gethelpon/10MinuteSolution/16575
+
+// SELECT * FROM TABLE(SNAPSHOT_APPL('SAMPLE', -1)) as t
+class perf_db2 extends adodb_perf{
+       var $createTableSQL = "CREATE TABLE adodb_logsql (
+                 created TIMESTAMP NOT NULL,
+                 sql0 varchar(250) NOT NULL,
+                 sql1 varchar(4000) NOT NULL,
+                 params varchar(3000) NOT NULL,
+                 tracer varchar(500) NOT NULL,
+                 timer decimal(16,6) NOT NULL
+               )";
+               
+       var $settings = array(
+       'Ratios',
+               'data cache hit ratio' => array('RATIO',
+                       "SELECT 
+                               case when 
sum(POOL_DATA_L_READS+POOL_INDEX_L_READS)=0 then 0 
+                               else 
100*(1-sum(POOL_DATA_P_READS+POOL_INDEX_P_READS)/sum(POOL_DATA_L_READS+POOL_INDEX_L_READS))
 end 
+                               FROM TABLE(SNAPSHOT_APPL('',-2)) as t",
+                       '=WarnCacheRatio'),
+                       
+       'Data Cache',
+               'data cache buffers' => array('DATAC',
+               'select sum(npages) from SYSCAT.BUFFERPOOLS',
+                       'See <a 
href=http://www7b.boulder.ibm.com/dmdd/library/techarticle/anshum/0107anshum.html#bufferpoolsize>tuning
 reference</a>.' ),
+               'cache blocksize' => array('DATAC',
+               'select avg(pagesize) from SYSCAT.BUFFERPOOLS',
+                       '' ),
+               'data cache size' => array('DATAC',
+               'select sum(npages*pagesize) from SYSCAT.BUFFERPOOLS',
+                       '' ),
+       'Connections',
+               'current connections' => array('SESS',
+                       "SELECT count(*) FROM TABLE(SNAPSHOT_APPL_INFO('',-2)) 
as t",
+                       ''),
+
+               false
+       );
+
+
+       function perf_db2(&$conn)
+       {
+               $this->conn =& $conn;
+       }
+       
+       function Explain($sql,$partial=false)
+       {
+               $save = $this->conn->LogSQL(false);
+               if ($partial) {
+                       $sqlq = $this->conn->qstr($sql.'%');
+                       $arr = $this->conn->GetArray("select distinct sql1 from 
adodb_logsql where sql1 like $sqlq");
+                       if ($arr) {
+                               foreach($arr as $row) {
+                                       $sql = reset($row);
+                                       if (crc32($sql) == $partial) break;
+                               }
+                       }
+               }
+               $qno = rand();
+               $ok = $this->conn->Execute("EXPLAIN PLAN SET QUERYNO=$qno FOR 
$sql");
+               ob_start();
+               if (!$ok) echo "<p>Have EXPLAIN tables been created?</p>";
+               else {
+                       $rs = $this->conn->Execute("select * from 
explain_statement where queryno=$qno");
+                       if ($rs) rs2html($rs);
+               }
+               $s = ob_get_contents();
+               ob_end_clean();
+               $this->conn->LogSQL($save);
+               
+               $s .= $this->Tracer($sql);
+               return $s;
+       }
+       
+       
+       function Tables()
+       {
+               $rs = $this->conn->Execute("select tabschema,tabname,card as 
rows,
+                       npages pages_used,fpages pages_allocated, tbspace 
tablespace  
+                       from syscat.tables where tabschema not in 
('SYSCAT','SYSIBM','SYSSTAT') order by 1,2");
+               return rs2html($rs,false,false,false,false);
+       }
+}
 ?>
\ No newline at end of file

Index: perf-informix.inc.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/adodb/perf/perf-informix.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- perf-informix.inc.php       29 Nov 2004 23:16:59 -0000      1.1
+++ perf-informix.inc.php       27 Jan 2005 14:43:45 -0000      1.2
@@ -1,70 +1,70 @@
-<?php
-/* 
-V4.54 5 Nov 2004  (c) 2000-2004 John Lim 
(jlim-l15XFKl8ZeYZ+IcD6AW/HA@xxxxxxxxxxxxxxxx). All rights reserved.
-  Released under both BSD license and Lesser GPL library license. 
-  Whenever there is any discrepancy between the two licenses, 
-  the BSD license will take precedence. See License.txt. 
-  Set tabs to 4 for best viewing.
-  
-  Latest version is available at http://adodb.sourceforge.net
-  
-  Library for basic performance monitoring and tuning 
-  
-*/
-
-// security - hide paths
-if (!defined('ADODB_DIR')) die();
-
-//
-// Thx to  Fernando Ortiz, mailto:fortiz#lacorona.com.mx
-// With info taken from http://www.oninit.com/oninit/sysmaster/index.html
-//
-class perf_informix extends adodb_perf{
-
-       // Maximum size on varchar upto 9.30 255 chars
-       // better truncate varchar to 255 than char(4000) ?
-       var $createTableSQL = "CREATE TABLE adodb_logsql (
-               created datetime year to second NOT NULL,
-               sql0 varchar(250) NOT NULL,
-               sql1 varchar(255) NOT NULL,
-               params varchar(255) NOT NULL,
-               tracer varchar(255) NOT NULL,
-               timer decimal(16,6) NOT NULL
-       )";
-       
-       var $tablesSQL = "select a.tabname tablename, ti_nptotal*2 size_in_k, 
ti_nextns extents, ti_nrows records from systables c, sysmaster:systabnames a, 
sysmaster:systabinfo b where c.tabname not matches 'sys*' and c.partnum = 
a.partnum and c.partnum = b.ti_partnum";
-       
-       var $settings = array(
-       'Ratios',
-               'data cache hit ratio' => array('RATIOH',
-               "select round((1-(wt.value / (rd.value + wr.value)))*100,2)
-               from sysmaster:sysprofile wr, sysmaster:sysprofile rd, 
sysmaster:sysprofile wt
-               where rd.name = 'pagreads' and
-               wr.name = 'pagwrites' and
-               wt.name = 'buffwts'",
-               '=WarnCacheRatio'),
-       'IO',
-               'data reads' => array('IO',
-               "select value from sysmaster:sysprofile where name='pagreads'",
-               'Page reads'),
-               
-               'data writes' => array('IO',
-               "select value from sysmaster:sysprofile where name='pagwrites'",
-               'Page writes'),
-       
-       'Connections',
-               'current connections' => array('SESS',
-               'select count(*) from sysmaster:syssessions',
-               'Number of sessions'),
-       
-       false
-       
-       );
-       
-       function perf_informix(&$conn)
-       {
-               $this->conn =& $conn;
-       }
-
-}
-?>
+<?php
+/* 
+V4.60 24 Jan 2005  (c) 2000-2005 John Lim 
(jlim-l15XFKl8ZeYZ+IcD6AW/HA@xxxxxxxxxxxxxxxx). All rights reserved.
+  Released under both BSD license and Lesser GPL library license. 
+  Whenever there is any discrepancy between the two licenses, 
+  the BSD license will take precedence. See License.txt. 
+  Set tabs to 4 for best viewing.
+  
+  Latest version is available at http://adodb.sourceforge.net
+  
+  Library for basic performance monitoring and tuning 
+  
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+//
+// Thx to  Fernando Ortiz, mailto:fortiz#lacorona.com.mx
+// With info taken from http://www.oninit.com/oninit/sysmaster/index.html
+//
+class perf_informix extends adodb_perf{
+
+       // Maximum size on varchar upto 9.30 255 chars
+       // better truncate varchar to 255 than char(4000) ?
+       var $createTableSQL = "CREATE TABLE adodb_logsql (
+               created datetime year to second NOT NULL,
+               sql0 varchar(250) NOT NULL,
+               sql1 varchar(255) NOT NULL,
+               params varchar(255) NOT NULL,
+               tracer varchar(255) NOT NULL,
+               timer decimal(16,6) NOT NULL
+       )";
+       
+       var $tablesSQL = "select a.tabname tablename, ti_nptotal*2 size_in_k, 
ti_nextns extents, ti_nrows records from systables c, sysmaster:systabnames a, 
sysmaster:systabinfo b where c.tabname not matches 'sys*' and c.partnum = 
a.partnum and c.partnum = b.ti_partnum";
+       
+       var $settings = array(
+       'Ratios',
+               'data cache hit ratio' => array('RATIOH',
+               "select round((1-(wt.value / (rd.value + wr.value)))*100,2)
+               from sysmaster:sysprofile wr, sysmaster:sysprofile rd, 
sysmaster:sysprofile wt
+               where rd.name = 'pagreads' and
+               wr.name = 'pagwrites' and
+               wt.name = 'buffwts'",
+               '=WarnCacheRatio'),
+       'IO',
+               'data reads' => array('IO',
+               "select value from sysmaster:sysprofile where name='pagreads'",
+               'Page reads'),
+               
+               'data writes' => array('IO',
+               "select value from sysmaster:sysprofile where name='pagwrites'",
+               'Page writes'),
+       
+       'Connections',
+               'current connections' => array('SESS',
+               'select count(*) from sysmaster:syssessions',
+               'Number of sessions'),
+       
+       false
+       
+       );
+       
+       function perf_informix(&$conn)
+       {
+               $this->conn =& $conn;
+       }
+
+}
+?>

Index: perf-mysql.inc.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/adodb/perf/perf-mysql.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- perf-mysql.inc.php  29 Nov 2004 23:16:59 -0000      1.1
+++ perf-mysql.inc.php  27 Jan 2005 14:43:45 -0000      1.2
@@ -1,259 +1,259 @@
-<?php
-/* 
-V4.54 5 Nov 2004  (c) 2000-2004 John Lim 
(jlim-l15XFKl8ZeYZ+IcD6AW/HA@xxxxxxxxxxxxxxxx). All rights reserved.
-  Released under both BSD license and Lesser GPL library license. 
-  Whenever there is any discrepancy between the two licenses, 
-  the BSD license will take precedence. See License.txt. 
-  Set tabs to 4 for best viewing.
-  
-  Latest version is available at http://adodb.sourceforge.net
-  
-  Library for basic performance monitoring and tuning 
-  
-*/
-
-// security - hide paths
-if (!defined('ADODB_DIR')) die();
-
-class perf_mysql extends adodb_perf{
-       
-       var $tablesSQL = 'show table status';
-       
-       var $createTableSQL = "CREATE TABLE adodb_logsql (
-                 created datetime NOT NULL,
-                 sql0 varchar(250) NOT NULL,
-                 sql1 text NOT NULL,
-                 params text NOT NULL,
-                 tracer text NOT NULL,
-                 timer decimal(16,6) NOT NULL
-               )";
-               
-       var $settings = array(
-       'Ratios',
-               'MyISAM cache hit ratio' => array('RATIO',
-                       '=GetKeyHitRatio',
-                       '=WarnCacheRatio'),
-               'InnoDB cache hit ratio' => array('RATIO',
-                       '=GetInnoDBHitRatio',
-                       '=WarnCacheRatio'),
-               'data cache hit ratio' => array('HIDE', # only if called
-                       '=FindDBHitRatio',
-                       '=WarnCacheRatio'),
-               'sql cache hit ratio' => array('RATIO',
-                       '=GetQHitRatio',
-                       ''),
-       'IO',
-               'data reads' => array('IO',
-                       '=GetReads',
-                       'Number of selects (Key_reads is not accurate)'),
-               'data writes' => array('IO',
-                       '=GetWrites',
-                       'Number of inserts/updates/deletes * coef (Key_writes 
is not accurate)'),
-               
-       'Data Cache',
-               'MyISAM data cache size' => array('DATAC',
-                       array("show variables", 'key_buffer_size'),
-                       '' ),
-               'BDB data cache size' => array('DATAC',
-                       array("show variables", 'bdb_cache_size'),
-                       '' ),
-               'InnoDB data cache size' => array('DATAC',
-                       array("show variables", 'innodb_buffer_pool_size'),
-                       '' ),
-       'Memory Usage',
-               'read buffer size' => array('CACHE',
-                       array("show variables", 'read_buffer_size'),
-                       '(per session)'),
-               'sort buffer size' => array('CACHE',
-                       array("show variables", 'sort_buffer_size'),
-                       'Size of sort buffer (per session)' ),
-               'table cache' => array('CACHE',
-                       array("show variables", 'table_cache'),
-                       'Number of tables to keep open'),
-       'Connections',  
-               'current connections' => array('SESS',
-                       array('show status','Threads_connected'),
-                       ''),
-               'max connections' => array( 'SESS',
-                       array("show variables",'max_connections'),
-                       ''),
-       
-               false
-       );
-       
-       function perf_mysql(&$conn)
-       {
-               $this->conn =& $conn;
-       }
-       
-       function Explain($sql,$partial=false)
-       {
-               
-               if (strtoupper(substr(trim($sql),0,6)) !== 'SELECT') return 
'<p>Unable to EXPLAIN non-select statement</p>';
-               $save = $this->conn->LogSQL(false);
-               if ($partial) {
-                       $sqlq = $this->conn->qstr($sql.'%');
-                       $arr = $this->conn->GetArray("select distinct sql1 from 
adodb_logsql where sql1 like $sqlq");
-                       if ($arr) {
-                               foreach($arr as $row) {
-                                       $sql = reset($row);
-                                       if (crc32($sql) == $partial) break;
-                               }
-                       }
-               }
-               $sql = str_replace('?',"''",$sql);
-               
-               if ($partial) {
-                       $sqlq = $this->conn->qstr($sql.'%');
-                       $sql = $this->conn->GetOne("select sql1 from 
adodb_logsql where sql1 like $sqlq");
-               }
-               
-               $s = '<p><b>Explain</b>: '.htmlspecialchars($sql).'</p>';
-               $rs = $this->conn->Execute('EXPLAIN '.$sql);
-               $s .= rs2html($rs,false,false,false,false);
-               $this->conn->LogSQL($save);
-               $s .= $this->Tracer($sql);
-               return $s;
-       }
-       
-       function Tables()
-       {
-               if (!$this->tablesSQL) return false;
-               
-               $rs = $this->conn->Execute($this->tablesSQL);
-               if (!$rs) return false;
-               
-               $html = rs2html($rs,false,false,false,false);
-               return $html;
-       }
-       
-       function GetReads()
-       {
-       global $ADODB_FETCH_MODE;
-               $save = $ADODB_FETCH_MODE;
-               $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
-               $rs = $this->conn->Execute('show status');
-               $ADODB_FETCH_MODE = $save;
-               
-               if (!$rs) return 0;
-               $val = 0;
-               while (!$rs->EOF) {
-                       switch($rs->fields[0]) {
-                       case 'Com_select': 
-                               $val = $rs->fields[1];
-                               $rs->Close();
-                               return $val;
-                       }
-                       $rs->MoveNext();
-               } 
-               
-               $rs->Close();
-               
-               return $val;
-       }
-       
-       function GetWrites()
-       {
-       global $ADODB_FETCH_MODE;
-               $save = $ADODB_FETCH_MODE;
-               $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
-               $rs = $this->conn->Execute('show status');
-               $ADODB_FETCH_MODE = $save;
-               
-               if (!$rs) return 0;
-               $val = 0.0;
-               while (!$rs->EOF) {
-                       switch($rs->fields[0]) {
-                       case 'Com_insert': 
-                               $val += $rs->fields[1]; break;
-                       case 'Com_delete': 
-                               $val += $rs->fields[1]; break;
-                       case 'Com_update': 
-                               $val += $rs->fields[1]/2;
-                               $rs->Close();
-                               return $val;
-                       }
-                       $rs->MoveNext();
-               } 
-               
-               $rs->Close();
-               
-               return $val;
-       }
-       
-       function FindDBHitRatio()
-       {
-               // first find out type of table
-               //$this->conn->debug=1;
-               $rs = $this->conn->Execute('show table status');
-               if (!$rs) return '';
-               $type = strtoupper($rs->fields[1]);
-               $rs->Close();
-               switch($type){
-               case 'MYISAM':
-               case 'ISAM':
-                       return $this->DBParameter('MyISAM cache hit ratio').' 
(MyISAM)';
-               case 'INNODB':
-                       return $this->DBParameter('InnoDB cache hit ratio').' 
(InnoDB)';
-               default:
-                       return $type.' not supported';
-               }
-               
-       }
-       
-       function GetQHitRatio()
-       {
-               //Total number of queries = Qcache_inserts + Qcache_hits + 
Qcache_not_cached
-               $hits = $this->_DBParameter(array("show status","Qcache_hits"));
-               $total = $this->_DBParameter(array("show 
status","Qcache_inserts"));
-               $total += $this->_DBParameter(array("show 
status","Qcache_not_cached"));
-               
-               $total += $hits;
-               if ($total) return ($hits*100)/$total;
-               return 0;
-       }
-       
-       /*
-               Use session variable to store Hit percentage, because MySQL
-               does not remember last value of SHOW INNODB STATUS hit ratio
-               
-               # 1st query to SHOW INNODB STATUS
-               0.00 reads/s, 0.00 creates/s, 0.00 writes/s
-               Buffer pool hit rate 1000 / 1000
-               
-               # 2nd query to SHOW INNODB STATUS
-               0.00 reads/s, 0.00 creates/s, 0.00 writes/s
-               No buffer pool activity since the last printout
-       */
-       function GetInnoDBHitRatio()
-       {
-       global $HTTP_SESSION_VARS;
-       
-               $rs = $this->conn->Execute('show innodb status');
-               if (!$rs || $rs->EOF) return 0;
-               $stat = $rs->fields[0];
-               $rs->Close();
-               $at = strpos($stat,'Buffer pool hit rate');
-               $stat = substr($stat,$at,200);
-               if (preg_match('!Buffer pool hit rate\s*([0-9]*) / 
([0-9]*)!',$stat,$arr)) {
-                       $val = 100*$arr[1]/$arr[2];
-                       $HTTP_SESSION_VARS['INNODB_HIT_PCT'] = $val;
-                       return $val;
-               } else {
-                       if (isset($HTTP_SESSION_VARS['INNODB_HIT_PCT'])) return 
$HTTP_SESSION_VARS['INNODB_HIT_PCT'];
-                       return 0;
-               }
-               return 0;
-       }
-       
-       function GetKeyHitRatio()
-       {
-               $hits = $this->_DBParameter(array("show 
status","Key_read_requests"));
-               $reqs = $this->_DBParameter(array("show status","Key_reads"));
-               if ($reqs == 0) return 0;
-               
-               return ($hits/($reqs+$hits))*100;
-       }
-       
-}
+<?php
+/* 
+V4.60 24 Jan 2005  (c) 2000-2005 John Lim 
(jlim-l15XFKl8ZeYZ+IcD6AW/HA@xxxxxxxxxxxxxxxx). All rights reserved.
+  Released under both BSD license and Lesser GPL library license. 
+  Whenever there is any discrepancy between the two licenses, 
+  the BSD license will take precedence. See License.txt. 
+  Set tabs to 4 for best viewing.
+  
+  Latest version is available at http://adodb.sourceforge.net
+  
+  Library for basic performance monitoring and tuning 
+  
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+class perf_mysql extends adodb_perf{
+       
+       var $tablesSQL = 'show table status';
+       
+       var $createTableSQL = "CREATE TABLE adodb_logsql (
+                 created datetime NOT NULL,
+                 sql0 varchar(250) NOT NULL,
+                 sql1 text NOT NULL,
+                 params text NOT NULL,
+                 tracer text NOT NULL,
+                 timer decimal(16,6) NOT NULL
+               )";
+               
+       var $settings = array(
+       'Ratios',
+               'MyISAM cache hit ratio' => array('RATIO',
+                       '=GetKeyHitRatio',
+                       '=WarnCacheRatio'),
+               'InnoDB cache hit ratio' => array('RATIO',
+                       '=GetInnoDBHitRatio',
+                       '=WarnCacheRatio'),
+               'data cache hit ratio' => array('HIDE', # only if called
+                       '=FindDBHitRatio',
+                       '=WarnCacheRatio'),
+               'sql cache hit ratio' => array('RATIO',
+                       '=GetQHitRatio',
+                       ''),
+       'IO',
+               'data reads' => array('IO',
+                       '=GetReads',
+                       'Number of selects (Key_reads is not accurate)'),
+               'data writes' => array('IO',
+                       '=GetWrites',
+                       'Number of inserts/updates/deletes * coef (Key_writes 
is not accurate)'),
+               
+       'Data Cache',
+               'MyISAM data cache size' => array('DATAC',
+                       array("show variables", 'key_buffer_size'),
+                       '' ),
+               'BDB data cache size' => array('DATAC',
+                       array("show variables", 'bdb_cache_size'),
+                       '' ),
+               'InnoDB data cache size' => array('DATAC',
+                       array("show variables", 'innodb_buffer_pool_size'),
+                       '' ),
+       'Memory Usage',
+               'read buffer size' => array('CACHE',
+                       array("show variables", 'read_buffer_size'),
+                       '(per session)'),
+               'sort buffer size' => array('CACHE',
+                       array("show variables", 'sort_buffer_size'),
+                       'Size of sort buffer (per session)' ),
+               'table cache' => array('CACHE',
+                       array("show variables", 'table_cache'),
+                       'Number of tables to keep open'),
+       'Connections',  
+               'current connections' => array('SESS',
+                       array('show status','Threads_connected'),
+                       ''),
+               'max connections' => array( 'SESS',
+                       array("show variables",'max_connections'),
+                       ''),
+       
+               false
+       );
+       
+       function perf_mysql(&$conn)
+       {
+               $this->conn =& $conn;
+       }
+       
+       function Explain($sql,$partial=false)
+       {
+               
+               if (strtoupper(substr(trim($sql),0,6)) !== 'SELECT') return 
'<p>Unable to EXPLAIN non-select statement</p>';
+               $save = $this->conn->LogSQL(false);
+               if ($partial) {
+                       $sqlq = $this->conn->qstr($sql.'%');
+                       $arr = $this->conn->GetArray("select distinct sql1 from 
adodb_logsql where sql1 like $sqlq");
+                       if ($arr) {
+                               foreach($arr as $row) {
+                                       $sql = reset($row);
+                                       if (crc32($sql) == $partial) break;
+                               }
+                       }
+               }
+               $sql = str_replace('?',"''",$sql);
+               
+               if ($partial) {
+                       $sqlq = $this->conn->qstr($sql.'%');
+                       $sql = $this->conn->GetOne("select sql1 from 
adodb_logsql where sql1 like $sqlq");
+               }
+               
+               $s = '<p><b>Explain</b>: '.htmlspecialchars($sql).'</p>';
+               $rs = $this->conn->Execute('EXPLAIN '.$sql);
+               $s .= rs2html($rs,false,false,false,false);
+               $this->conn->LogSQL($save);
+               $s .= $this->Tracer($sql);
+               return $s;
+       }
+       
+       function Tables()
+       {
+               if (!$this->tablesSQL) return false;
+               
+               $rs = $this->conn->Execute($this->tablesSQL);
+               if (!$rs) return false;
+               
+               $html = rs2html($rs,false,false,false,false);
+               return $html;
+       }
+       
+       function GetReads()
+       {
+       global $ADODB_FETCH_MODE;
+               $save = $ADODB_FETCH_MODE;
+               $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+               $rs = $this->conn->Execute('show status');
+               $ADODB_FETCH_MODE = $save;
+               
+               if (!$rs) return 0;
+               $val = 0;
+               while (!$rs->EOF) {
+                       switch($rs->fields[0]) {
+                       case 'Com_select': 
+                               $val = $rs->fields[1];
+                               $rs->Close();
+                               return $val;
+                       }
+                       $rs->MoveNext();
+               } 
+               
+               $rs->Close();
+               
+               return $val;
+       }
+       
+       function GetWrites()
+       {
+       global $ADODB_FETCH_MODE;
+               $save = $ADODB_FETCH_MODE;
+               $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+               $rs = $this->conn->Execute('show status');
+               $ADODB_FETCH_MODE = $save;
+               
+               if (!$rs) return 0;
+               $val = 0.0;
+               while (!$rs->EOF) {
+                       switch($rs->fields[0]) {
+                       case 'Com_insert': 
+                               $val += $rs->fields[1]; break;
+                       case 'Com_delete': 
+                               $val += $rs->fields[1]; break;
+                       case 'Com_update': 
+                               $val += $rs->fields[1]/2;
+                               $rs->Close();
+                               return $val;
+                       }
+                       $rs->MoveNext();
+               } 
+               
+               $rs->Close();
+               
+               return $val;
+       }
+       
+       function FindDBHitRatio()
+       {
+               // first find out type of table
+               //$this->conn->debug=1;
+               $rs = $this->conn->Execute('show table status');
+               if (!$rs) return '';
+               $type = strtoupper($rs->fields[1]);
+               $rs->Close();
+               switch($type){
+               case 'MYISAM':
+               case 'ISAM':
+                       return $this->DBParameter('MyISAM cache hit ratio').' 
(MyISAM)';
+               case 'INNODB':
+                       return $this->DBParameter('InnoDB cache hit ratio').' 
(InnoDB)';
+               default:
+                       return $type.' not supported';
+               }
+               
+       }
+       
+       function GetQHitRatio()
+       {
+               //Total number of queries = Qcache_inserts + Qcache_hits + 
Qcache_not_cached
+               $hits = $this->_DBParameter(array("show status","Qcache_hits"));
+               $total = $this->_DBParameter(array("show 
status","Qcache_inserts"));
+               $total += $this->_DBParameter(array("show 
status","Qcache_not_cached"));
+               
+               $total += $hits;
+               if ($total) return ($hits*100)/$total;
+               return 0;
+       }
+       
+       /*
+               Use session variable to store Hit percentage, because MySQL
+               does not remember last value of SHOW INNODB STATUS hit ratio
+               
+               # 1st query to SHOW INNODB STATUS
+               0.00 reads/s, 0.00 creates/s, 0.00 writes/s
+               Buffer pool hit rate 1000 / 1000
+               
+               # 2nd query to SHOW INNODB STATUS
+               0.00 reads/s, 0.00 creates/s, 0.00 writes/s
+               No buffer pool activity since the last printout
+       */
+       function GetInnoDBHitRatio()
+       {
+       global $HTTP_SESSION_VARS;
+       
+               $rs = $this->conn->Execute('show innodb status');
+               if (!$rs || $rs->EOF) return 0;
+               $stat = $rs->fields[0];
+               $rs->Close();
+               $at = strpos($stat,'Buffer pool hit rate');
+               $stat = substr($stat,$at,200);
+               if (preg_match('!Buffer pool hit rate\s*([0-9]*) / 
([0-9]*)!',$stat,$arr)) {
+                       $val = 100*$arr[1]/$arr[2];
+                       $HTTP_SESSION_VARS['INNODB_HIT_PCT'] = $val;
+                       return $val;
+               } else {
+                       if (isset($HTTP_SESSION_VARS['INNODB_HIT_PCT'])) return 
$HTTP_SESSION_VARS['INNODB_HIT_PCT'];
+                       return 0;
+               }
+               return 0;
+       }
+       
+       function GetKeyHitRatio()
+       {
+               $hits = $this->_DBParameter(array("show 
status","Key_read_requests"));
+               $reqs = $this->_DBParameter(array("show status","Key_reads"));
+               if ($reqs == 0) return 0;
+               
+               return ($hits/($reqs+$hits))*100;
+       }
+       
+}
 ?>
\ No newline at end of file



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl


<Prev in Thread] Current Thread [Next in Thread>