3 V5.16 26 Mar 2012 (c) 2000-2012 John Lim (jlim#natsoft.com). All rights reserved.
4 Released under both BSD license and Lesser GPL library license.
5 Whenever there is any discrepancy between the two licenses,
6 the BSD license will take precedence. See License.txt.
7 Set tabs to 4 for best viewing.
9 Latest version is available at http://adodb.sourceforge.net
11 Library for basic performance monitoring and tuning
15 // security - hide paths
16 if (!defined('ADODB_DIR')) die();
18 // Simple guide to configuring db2: so-so http://www.devx.com/gethelpon/10MinuteSolution/16575
20 // SELECT * FROM TABLE(SNAPSHOT_APPL('SAMPLE', -1)) as t
21 class perf_db2
extends adodb_perf
{
22 var $createTableSQL = "CREATE TABLE adodb_logsql (
23 created TIMESTAMP NOT NULL,
24 sql0 varchar(250) NOT NULL,
25 sql1 varchar(4000) NOT NULL,
26 params varchar(3000) NOT NULL,
27 tracer varchar(500) NOT NULL,
28 timer decimal(16,6) NOT NULL
31 var $settings = array(
33 'data cache hit ratio' => array('RATIO',
35 case when sum(POOL_DATA_L_READS+POOL_INDEX_L_READS)=0 then 0
36 else 100*(1-sum(POOL_DATA_P_READS+POOL_INDEX_P_READS)/sum(POOL_DATA_L_READS+POOL_INDEX_L_READS)) end
37 FROM TABLE(SNAPSHOT_APPL('',-2)) as t",
41 'data cache buffers' => array('DATAC',
42 'select sum(npages) from SYSCAT.BUFFERPOOLS',
43 'See <a href=http://www7b.boulder.ibm.com/dmdd/library/techarticle/anshum/0107anshum.html#bufferpoolsize>tuning reference</a>.' ),
44 'cache blocksize' => array('DATAC',
45 'select avg(pagesize) from SYSCAT.BUFFERPOOLS',
47 'data cache size' => array('DATAC',
48 'select sum(npages*pagesize) from SYSCAT.BUFFERPOOLS',
51 'current connections' => array('SESS',
52 "SELECT count(*) FROM TABLE(SNAPSHOT_APPL_INFO('',-2)) as t",
59 function perf_db2(&$conn)
64 function Explain($sql,$partial=false)
66 $save = $this->conn
->LogSQL(false);
68 $sqlq = $this->conn
->qstr($sql.'%');
69 $arr = $this->conn
->GetArray("select distinct sql1 from adodb_logsql where sql1 like $sqlq");
71 foreach($arr as $row) {
73 if (crc32($sql) == $partial) break;
78 $ok = $this->conn
->Execute("EXPLAIN PLAN SET QUERYNO=$qno FOR $sql");
80 if (!$ok) echo "<p>Have EXPLAIN tables been created?</p>";
82 $rs = $this->conn
->Execute("select * from explain_statement where queryno=$qno");
83 if ($rs) rs2html($rs);
85 $s = ob_get_contents();
87 $this->conn
->LogSQL($save);
89 $s .= $this->Tracer($sql);
96 $rs = $this->conn
->Execute("select tabschema,tabname,card as rows,
97 npages pages_used,fpages pages_allocated, tbspace tablespace
98 from syscat.tables where tabschema not in ('SYSCAT','SYSIBM','SYSSTAT') order by 1,2");
99 return rs2html($rs,false,false,false,false);