TYPO3 CMS  TYPO3_7-6
perf-db2.inc.php
Go to the documentation of this file.
1 <?php
2 /*
3 @version v5.20.3 01-Jan-2016
4 @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
5 @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
6  Released under both BSD license and Lesser GPL library license.
7  Whenever there is any discrepancy between the two licenses,
8  the BSD license will take precedence. See License.txt.
9  Set tabs to 4 for best viewing.
10 
11  Latest version is available at http://adodb.sourceforge.net
12 
13  Library for basic performance monitoring and tuning
14 
15 */
16 
17 // security - hide paths
18 if (!defined('ADODB_DIR')) die();
19 
20 // Simple guide to configuring db2: so-so http://www.devx.com/gethelpon/10MinuteSolution/16575
21 
22 // SELECT * FROM TABLE(SNAPSHOT_APPL('SAMPLE', -1)) as t
23 class perf_db2 extends adodb_perf{
24  var $createTableSQL = "CREATE TABLE adodb_logsql (
25  created TIMESTAMP NOT NULL,
26  sql0 varchar(250) NOT NULL,
27  sql1 varchar(4000) NOT NULL,
28  params varchar(3000) NOT NULL,
29  tracer varchar(500) NOT NULL,
30  timer decimal(16,6) NOT NULL
31  )";
32 
33  var $settings = array(
34  'Ratios',
35  'data cache hit ratio' => array('RATIO',
36  "SELECT
37  case when sum(POOL_DATA_L_READS+POOL_INDEX_L_READS)=0 then 0
38  else 100*(1-sum(POOL_DATA_P_READS+POOL_INDEX_P_READS)/sum(POOL_DATA_L_READS+POOL_INDEX_L_READS)) end
39  FROM TABLE(SNAPSHOT_APPL('',-2)) as t",
40  '=WarnCacheRatio'),
41 
42  'Data Cache',
43  'data cache buffers' => array('DATAC',
44  'select sum(npages) from SYSCAT.BUFFERPOOLS',
45  'See <a href=http://www7b.boulder.ibm.com/dmdd/library/techarticle/anshum/0107anshum.html#bufferpoolsize>tuning reference</a>.' ),
46  'cache blocksize' => array('DATAC',
47  'select avg(pagesize) from SYSCAT.BUFFERPOOLS',
48  '' ),
49  'data cache size' => array('DATAC',
50  'select sum(npages*pagesize) from SYSCAT.BUFFERPOOLS',
51  '' ),
52  'Connections',
53  'current connections' => array('SESS',
54  "SELECT count(*) FROM TABLE(SNAPSHOT_APPL_INFO('',-2)) as t",
55  ''),
56 
57  false
58  );
59 
60 
61  function __construct(&$conn)
62  {
63  $this->conn = $conn;
64  }
65 
66  function Explain($sql,$partial=false)
67  {
68  $save = $this->conn->LogSQL(false);
69  if ($partial) {
70  $sqlq = $this->conn->qstr($sql.'%');
71  $arr = $this->conn->GetArray("select distinct sql1 from adodb_logsql where sql1 like $sqlq");
72  if ($arr) {
73  foreach($arr as $row) {
74  $sql = reset($row);
75  if (crc32($sql) == $partial) break;
76  }
77  }
78  }
79  $qno = rand();
80  $ok = $this->conn->Execute("EXPLAIN PLAN SET QUERYNO=$qno FOR $sql");
81  ob_start();
82  if (!$ok) echo "<p>Have EXPLAIN tables been created?</p>";
83  else {
84  $rs = $this->conn->Execute("select * from explain_statement where queryno=$qno");
85  if ($rs) rs2html($rs);
86  }
87  $s = ob_get_contents();
88  ob_end_clean();
89  $this->conn->LogSQL($save);
90 
91  $s .= $this->Tracer($sql);
92  return $s;
93  }
94 
101  function Tables($throwaway=0)
102  {
103  $rs = $this->conn->Execute("select tabschema,tabname,card as rows,
104  npages pages_used,fpages pages_allocated, tbspace tablespace
105  from syscat.tables where tabschema not in ('SYSCAT','SYSIBM','SYSSTAT') order by 1,2");
106  return rs2html($rs,false,false,false,false);
107  }
108 }
Explain($sql, $partial=false)
Tables($throwaway=0)
if(isset($_REQUEST['nrows'])) else $rs
Definition: server.php:94
rs2html(&$rs, $ztabhtml=false, $zheaderarray=false, $htmlspecialchars=true, $echo=true)
Definition: tohtml.inc.php:43
__construct(&$conn)
$sql
Definition: server.php:84