]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/WikiDB/adodb/docs/docs-perf.htm
Upgrade adodb
[SourceForge/phpwiki.git] / lib / WikiDB / adodb / docs / docs-perf.htm
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
3 <head>
4   <title>ADOdb Performance Monitoring Library</title>
5   <style type="text/css">
6 body, td {
7 /*font-family: Arial, Helvetica, sans-serif;*/
8 font-size: 11pt;
9 }
10 pre {
11 font-size: 9pt;
12 background-color: #EEEEEE; padding: .5em; margin: 0px;
13 }
14 .toplink {
15 font-size: 8pt;
16 }
17   </style>
18 </head>
19 <body>
20 <h3>The ADOdb Performance Monitoring Library</h3>
21 <p>V5.18 3 Sep 2012  (c) 2000-2010 John Lim (jlim#natsoft.com)</p>
22 <p><font size="1">This software is dual licensed using BSD-Style and
23 LGPL. This means you can use it in compiled proprietary and commercial
24 products.</font></p>
25 <p>Useful ADOdb links: <a href="http://adodb.sourceforge.net/#download">Download</a>
26 &nbsp; <a href="http://adodb.sourceforge.net/#docs">Other Docs</a>
27 </p>
28 <h3>Introduction</h3>
29 <p>This module, part of the ADOdb package, provides both CLI and HTML
30 interfaces for viewing key performance indicators of your database.
31 This is very useful because web apps such as the popular phpMyAdmin
32 currently do not provide effective database health monitoring tools.
33 The module provides the following: </p>
34 <ul>
35   <li>A quick health check of your database server using <code>$perf-&gt;HealthCheck()</code>
36 or <code>$perf-&gt;HealthCheckCLI()</code>. </li>
37   <li>User interface for performance monitoring, <code>$perf-&gt;UI()</code>.
38 This UI displays:
39     <ul>
40       <li>the health check, </li>
41       <li>all SQL logged and their query plans, </li>
42       <li>a list of all tables in the current database</li>
43       <li>an interface to continiously poll the server for key
44 performance indicators such as CPU, Hit Ratio, Disk I/O</li>
45       <li>a form where you can enter and run SQL interactively.</li>
46     </ul>
47   </li>
48   <li>Gives you an API to build database monitoring tools for a server
49 farm, for example calling <code>$perf-&gt;DBParameter('data cache hit
50 ratio')</code> returns this very important statistic in a database
51 independant manner. </li>
52 </ul>
53 <p>ADOdb also has the ability to log all SQL executed, using <a
54  href="docs-adodb.htm#logsql">LogSQL</a>. All SQL logged can be
55 analyzed through the performance monitor <a href="#ui">UI</a>. In the <i>View
56 SQL</i> mode, we categorize the SQL into 3 types:
57 </p>
58 <ul>
59   <li><b>Suspicious SQL</b>: queries with high average execution times,
60 and are potential candidates for rewriting</li>
61   <li><b>Expensive SQL</b>: queries with high total execution times
62 (#executions * avg execution time). Optimizing these queries will
63 reduce your database server load.</li>
64   <li><b>Invalid SQL</b>: queries that generate errors.</li>
65 </ul>
66 <p>Each query is hyperlinked to a description of the query plan, and
67 every PHP script that executed that query is also shown.</p>
68 <p>Please note that the information presented is a very basic database
69 health check, and does not provide a complete overview of database
70 performance. Although some attempt has been made to make it work across
71 multiple databases in the same way, it is impossible to do so. For the
72 health check, we do try to display the following key database
73 parameters for all drivers:</p>
74 <ul>
75   <li><b>data cache size</b> - The amount of memory allocated to the
76 cache.</li>
77   <li><b>data cache hit ratio</b> - A measure of how effective the
78 cache is, as a percentage. The higher, the better.</li>
79   <li><b>current connections</b> - The number of sessions currently
80 connected to the database. </li>
81 </ul>
82 <p>You will need to connect to the database as an administrator to view
83 most of the parameters. </p>
84 <p>Code improvements as very welcome, particularly adding new database
85 parameters and automated tuning hints.</p>
86 <a name="usage"></a>
87 <h3>Usage</h3>
88 <p>Currently, the following drivers: <em>mysql</em>, <em>postgres</em>,
89 <em>oci8</em>, <em>mssql</em>, <i>informix</i> and <em>db2</em> are
90 supported. To create a new performance monitor, call NewPerfMonitor( )
91 as demonstrated below: </p>
92 <pre>&lt;?php<br>include_once('adodb.inc.php');<br>session_start(); <font
93  color="#006600"># session variables required for monitoring</font><br>$conn = ADONewConnection($driver);<br>$conn-&gt;Connect($server,$user,$pwd,$db);<br>$perf =&amp; NewPerfMonitor($conn);<br>$perf-&gt;UI($pollsecs=5);<br>?&gt;<br></pre>
94 <p>It is also possible to retrieve a single database parameter:</p>
95 <pre>$size = $perf-&gt;DBParameter('data cache size');<br></pre>
96 <p>
97 Thx to Fernando Ortiz for the informix module. </p>
98 <h3>Methods</h3>
99 <a name="ui"></a>
100 <p><font face="Courier New, Courier, mono">function <b>UI($pollsecs=5)</b></font></p>
101 <p>Creates a web-based user interface for performance monitoring. When
102 you click on Poll, server statistics will be displayed every $pollsecs
103 seconds. See <a href="#usage">Usage</a> above. </p>
104 <p>Since 4.11, we allow users to enter and run SQL interactively via
105 the "Run SQL" link. To disable this for security reasons, set this
106 constant before calling $perf-&gt;UI(). </p>
107 <p> </p>
108 <pre>define('ADODB_PERF_NO_RUN_SQL',1);</pre>
109 <p>Sample output follows below:</p>
110 <table bgcolor="lightyellow" border="1" width="100%">
111   <tbody>
112     <tr>
113       <td> <b><a href="http://php.weblogs.com/adodb?perf=1">ADOdb</a>
114 Performance Monitor</b> for localhost, db=test<br>
115       <font size="-1">PostgreSQL 7.3.2 on i686-pc-cygwin, compiled by
116 GCC gcc (GCC) 3.2 20020927 (prerelease)</font></td>
117     </tr>
118     <tr>
119       <td> <a href="#">Performance Stats</a> &nbsp; <a href="#">View
120 SQL</a> &nbsp; <a href="#">View Tables</a> &nbsp; <a href="#">Poll
121 Stats</a></td>
122     </tr>
123   </tbody>
124 </table>
125 <table bgcolor="white" border="1">
126   <tbody>
127     <tr>
128       <td colspan="3">
129       <h3>postgres7</h3>
130       </td>
131     </tr>
132     <tr>
133       <td><b>Parameter</b></td>
134       <td><b>Value</b></td>
135       <td><b>Description</b></td>
136     </tr>
137     <tr bgcolor="#f0f0f0">
138       <td colspan="3"><i>Ratios</i> &nbsp;</td>
139     </tr>
140     <tr>
141       <td>statistics collector</td>
142       <td>TRUE</td>
143       <td>Value must be TRUE to enable hit ratio statistics (<i>stats_start_collector</i>,<i>stats_row_level</i>
144 and <i>stats_block_level</i> must be set to true in postgresql.conf)</td>
145     </tr>
146     <tr>
147       <td>data cache hit ratio</td>
148       <td>99.7967555299239</td>
149       <td>&nbsp;</td>
150     </tr>
151     <tr bgcolor="#f0f0f0">
152       <td colspan="3"><i>IO</i> &nbsp;</td>
153     </tr>
154     <tr>
155       <td>data reads</td>
156       <td>125</td>
157       <td>&nbsp; </td>
158     </tr>
159     <tr>
160       <td>data writes</td>
161       <td>21.78125000000000000</td>
162       <td>Count of inserts/updates/deletes * coef</td>
163     </tr>
164     <tr bgcolor="#f0f0f0">
165       <td colspan="3"><i>Data Cache</i> &nbsp;</td>
166     </tr>
167     <tr>
168       <td>data cache buffers</td>
169       <td>640</td>
170       <td>Number of cache buffers. <a
171  href="http://www.varlena.com/GeneralBits/Tidbits/perf.html#basic">Tuning</a></td>
172     </tr>
173     <tr>
174       <td>cache blocksize</td>
175       <td>8192</td>
176       <td>(estimate)</td>
177     </tr>
178     <tr>
179       <td>data cache size</td>
180       <td>5M</td>
181       <td>&nbsp;</td>
182     </tr>
183     <tr>
184       <td>operating system cache size</td>
185       <td>80M</td>
186       <td>(effective cache size)</td>
187     </tr>
188     <tr bgcolor="#f0f0f0">
189       <td colspan="3"><i>Memory Usage</i> &nbsp;</td>
190     </tr>
191     <tr>
192       <td>sort buffer size</td>
193       <td>1M</td>
194       <td>Size of sort buffer (per query)</td>
195     </tr>
196     <tr bgcolor="#f0f0f0">
197       <td colspan="3"><i>Connections</i> &nbsp;</td>
198     </tr>
199     <tr>
200       <td>current connections</td>
201       <td>0</td>
202       <td>&nbsp;</td>
203     </tr>
204     <tr>
205       <td>max connections</td>
206       <td>32</td>
207       <td>&nbsp;</td>
208     </tr>
209     <tr bgcolor="#f0f0f0">
210       <td colspan="3"><i>Parameters</i> &nbsp;</td>
211     </tr>
212     <tr>
213       <td>rollback buffers</td>
214       <td>8</td>
215       <td>WAL buffers</td>
216     </tr>
217     <tr>
218       <td>random page cost</td>
219       <td>4</td>
220       <td>Cost of doing a seek (default=4). See <a
221  href="http://www.varlena.com/GeneralBits/Tidbits/perf.html#less">random_page_cost</a></td>
222     </tr>
223   </tbody>
224 </table>
225 <p><font face="Courier New, Courier, mono">function <b>HealthCheck</b>()</font></p>
226 <p>Returns database health check parameters as a HTML table. You will
227 need to echo or print the output of this function,</p>
228 <p><font face="Courier New, Courier, mono">function <b>HealthCheckCLI</b>()</font></p>
229 <p>Returns database health check parameters formatted for a command
230 line interface. You will need to echo or print the output of this
231 function. Sample output for mysql:</p>
232 <pre>-- Ratios -- <br>          MyISAM cache hit ratio =gt; 56.5635738832 <br>          InnoDB cache hit ratio =gt; 0 <br>             sql cache hit ratio =gt; 0 <br> -- IO -- <br>                      data reads =gt; 2622 <br>                     data writes =gt; 2415.5 <br> -- Data Cache -- <br>          MyISAM data cache size =gt; 512K <br>             BDB data cache size =gt; 8388600<br>          InnoDB data cache size =gt; 8M<br> -- Memory Pools -- <br>                read buffer size =gt; 131072 <br>                sort buffer size =gt; 65528 <br>                     table cache =gt; 4 <br> -- Connections -- <br>             current connections =gt; 3<br>                 max connections =gt; 100</pre>
233 <p><font face="Courier New, Courier, mono">function <b>Poll</b>($pollSecs=5)
234 </font> </p>
235 <p> Run in infinite loop, displaying the following information every
236 $pollSecs. This will not work properly if output buffering is enabled.
237 In the example below, $pollSecs=3:
238 </p>
239 <pre>Accumulating statistics...<br> Time   WS-CPU%   Hit%   Sess        Reads/s          Writes/s<br>11:08:30    0.7  56.56      1         0.0000            0.0000<br>11:08:33    1.8  56.56      2         0.0000            0.0000<br>11:08:36   11.1  56.55      3         2.5000            0.0000<br>11:08:39    9.8  56.55      2         3.1121            0.0000<br>11:08:42    2.8  56.55      1         0.0000            0.0000<br>11:08:45    7.4  56.55      2         0.0000            1.5000<br></pre>
240 <p><b>WS-CPU%</b> is the Web Server CPU load of the server that PHP is
241 running from (eg. the database client), and not the database. The <b>Hit%</b>
242 is the data cache hit ratio. <b>Sess</b> is the current number of
243 sessions connected to the database. If you are using persistent
244 connections, this should not change much. The <b>Reads/s</b> and <b>Writes/s</b>
245 are synthetic values to give the viewer a rough guide to I/O, and are
246 not to be taken literally. </p>
247 <p><font face="Courier New, Courier, mono">function <b>SuspiciousSQL</b>($numsql=10)</font></p>
248 <p>Returns SQL which have high average execution times as a HTML table.
249 Each sql statement
250 is hyperlinked to a new window which details the execution plan and the
251 scripts that execute this SQL.
252 </p>
253 <p> The number of statements returned is determined by $numsql. Data is
254 taken from the adodb_logsql table, where the sql statements are logged
255 when
256 $connection-&gt;LogSQL(true) is enabled. The adodb_logsql table is
257 populated using <a href="docs-adodb.htm#logsql">$conn-&gt;LogSQL</a>.
258 </p>
259 <p>For Oracle, Ixora Suspicious SQL returns a list of SQL statements
260 that are most cache intensive as a HTML table. These are data intensive
261 SQL statements that could benefit most from tuning. </p>
262 <p><font face="Courier New, Courier, mono">function <b>ExpensiveSQL</b>($numsql=10)</font></p>
263 <p>Returns SQL whose total execution time (avg time * #executions) is
264 high as a HTML table. Each sql statement
265 is hyperlinked to a new window which details the execution plan and the
266 scripts that execute this SQL.
267 </p>
268 <p> The number of statements returned is determined by $numsql. Data is
269 taken from the adodb_logsql table, where the sql statements are logged
270 when
271 $connection-&gt;LogSQL(true) is enabled. The adodb_logsql table is
272 populated using <a href="docs-adodb.htm#logsql">$conn-&gt;LogSQL</a>.
273 </p>
274 <p>For Oracle, Ixora Expensive SQL returns a list of SQL statements
275 that are taking the most CPU load when run.
276 </p>
277 <p><font face="Courier New, Courier, mono">function <b>InvalidSQL</b>($numsql=10)</font></p>
278 <p>Returns a list of invalid SQL as an HTML table.
279 </p>
280 <p>Data is taken from the adodb_logsql table, where the sql statements
281 are logged when
282 $connection-&gt;LogSQL(true) is enabled.
283 </p>
284 <p><font face="Courier New, Courier, mono">function <b>Tables</b>($orderby=1)</font></p>
285 <p>Returns information on all tables in a database, with the first two
286 fields containing the table name and table size, the remaining fields
287 depend on the database driver. If $orderby is set to 1, it will sort by
288 name. If $orderby is set to 2, then it will sort by table size. Some
289 database drivers (mssql and mysql) will ignore the $orderby clause. For
290 postgresql, the information is up-to-date since the last <i>vacuum</i>.
291 Not supported currently for db2.</p>
292 <h3>Raw Functions</h3>
293 <p>Raw functions return values without any formatting.</p>
294 <p><font face="Courier New, Courier, mono">function <b>DBParameter</b>($paramname)</font></p>
295 <p>Returns the value of a database parameter, such as
296 $this-&gt;DBParameter("data cache size").</p>
297 <p><font face="Courier New, Courier, mono">function <b>CPULoad</b>()</font></p>
298 <p>Returns the CPU load of the database client (NOT THE SERVER) as a
299 percentage. Only works for Linux and Windows. For Windows, WMI must be
300 available.</p>
301 <h3>$ADODB_PERF_MIN</h3>
302 <p>New in adodb 4.97/5.03 is this global variable, which controls whether sql timings which are too small are not saved. Currently it defaults 
303 to 0.05 (seconds). This means that all sql's which are faster than 0.05 seconds to execute are not saved.
304 <h3>Format of $settings Property</h3>
305 <p> To create new database parameters, you need to understand
306 $settings. The $settings data structure is an associative array. Each
307 element of the array defines a database parameter. The key is the name
308 of the database parameter. If no key is defined, then it is assumed to
309 be a section break, and the value is the name of the section break. If
310 this is too confusing, looking at the source code will help a lot!</p>
311 <p> Each database parameter is itself an array consisting of the
312 following elements:</p>
313 <ol start="0">
314   <li> Category code, used to group related db parameters. If the
315 category code is 'HIDE', then
316 the database parameter is not shown when HTML() is called. <br>
317   </li>
318   <li> either
319     <ol type="a">
320       <li>sql string to retrieve value, eg. "select value from
321 v\$parameter where name='db_block_size'", </li>
322       <li>array holding sql string and field to look for, e.g.
323 array('show variables','table_cache'); optional 3rd parameter is the
324 $rs-&gt;fields[$index] to use (otherwise $index=1), and optional 4th
325 parameter is a constant to multiply the result with (typically 100 for
326 percentage calculations),</li>
327       <li>a string prefixed by =, then a PHP method of the class is
328 invoked, e.g. to invoke $this-&gt;GetIndexValue(), set this array
329 element to '=GetIndexValue', <br>
330       </li>
331     </ol>
332   </li>
333   <li> Description of database parameter. If description begins with an
334 =, then it is interpreted as a method call, just as in (1c) above,
335 taking one parameter, the current value. E.g. '=GetIndexDescription'
336 will invoke $this-&gt;GetIndexDescription($val). This is useful for
337 generating tuning suggestions. For an example, see WarnCacheRatio().</li>
338 </ol>
339 <p>Example from MySQL, table_cache database parameter:</p>
340 <pre>'table cache' =gt; array('CACHE',            # category code<br>   array("show variables", 'table_cache'), # array (type 1b)<br>   'Number of tables to keep open'),       # description</pre>
341 <h3>Example Health Check Output</h3>
342 <p><a href="#db2">db2</a> <a href="#informix">informix</a> <a
343  href="#mysql">mysql</a> <a href="#mssql">mssql</a> <a href="#oci8">oci8</a>
344 <a href="#postgres">postgres</a></p>
345 <p><a name="db2"></a></p>
346 <table bgcolor="white" border="1">
347   <tbody>
348     <tr>
349       <td colspan="3">
350       <h3>db2</h3>
351       </td>
352     </tr>
353     <tr>
354       <td><b>Parameter</b></td>
355       <td><b>Value</b></td>
356       <td><b>Description</b></td>
357     </tr>
358     <tr bgcolor="#f0f0f0">
359       <td colspan="3"><i>Ratios</i> &nbsp;</td>
360     </tr>
361     <tr bgcolor="#ffffff">
362       <td>data cache hit ratio</td>
363       <td>0 &nbsp; </td>
364       <td>&nbsp;</td>
365     </tr>
366     <tr bgcolor="#f0f0f0">
367       <td colspan="3"><i>Data Cache</i></td>
368     </tr>
369     <tr bgcolor="#ffffff">
370       <td>data cache buffers</td>
371       <td>250 &nbsp; </td>
372       <td>See <a
373  href="http://www7b.boulder.ibm.com/dmdd/library/techarticle/anshum/0107anshum.html#bufferpoolsize">tuning
374 reference</a>.</td>
375     </tr>
376     <tr bgcolor="#ffffff">
377       <td>cache blocksize</td>
378       <td>4096 &nbsp; </td>
379       <td>&nbsp;</td>
380     </tr>
381     <tr bgcolor="#ffffff">
382       <td>data cache size</td>
383       <td>1000K &nbsp; </td>
384       <td>&nbsp;</td>
385     </tr>
386     <tr bgcolor="#f0f0f0">
387       <td colspan="3"><i>Connections</i></td>
388     </tr>
389     <tr bgcolor="#ffffff">
390       <td>current connections</td>
391       <td>2 &nbsp; </td>
392       <td>&nbsp;</td>
393     </tr>
394   </tbody>
395 </table>
396 <p>&nbsp;</p>
397 <p><a name="informix"></a>
398 <table bgcolor="white" border="1">
399   <tbody>
400     <tr>
401       <td colspan="3">
402       <h3>informix</h3>
403       </td>
404     </tr>
405     <tr>
406       <td><b>Parameter</b></td>
407       <td><b>Val
408 ue</b></td>
409       <td><b>Description</b></td>
410     </tr>
411     <tr bgcolor="#f0f0f0">
412       <td colspan="3"><i>Ratios</i> &nbsp;</td>
413     </tr>
414     <tr>
415       <td>data cache hit
416 ratio</td>
417       <td>95.89</td>
418       <td>&nbsp;</td>
419     </tr>
420     <tr bgcolor="#f0f0f0">
421       <td colspan="3"><i>IO</i> &nbsp;</td>
422     </tr>
423     <tr>
424       <td>data
425 reads</td>
426       <td>1883884</td>
427       <td>Page reads</td>
428     </tr>
429     <tr>
430       <td>data writes</td>
431       <td>1716724</td>
432       <td>Page writes</td>
433     </tr>
434     <tr bgcolor="#f0f0f0">
435       <td colspan="3"><i>Connections</i>
436 &nbsp;</td>
437     </tr>
438     <tr>
439       <td>current connections</td>
440       <td>263.0</td>
441       <td>Number of
442 sessions</td>
443     </tr>
444   </tbody>
445 </table>
446 </p>
447 <p>&nbsp;</p>
448 <p><a name="mysql" id="mysql"></a></p>
449 <table bgcolor="white" border="1">
450   <tbody>
451     <tr>
452       <td colspan="3">
453       <h3>mysql</h3>
454       </td>
455     </tr>
456     <tr>
457       <td><b>Parameter</b></td>
458       <td><b>Value</b></td>
459       <td><b>Description</b></td>
460     </tr>
461     <tr bgcolor="#f0f0f0">
462       <td colspan="3"><i>Ratios</i> &nbsp;</td>
463     </tr>
464     <tr>
465       <td>MyISAM cache hit ratio</td>
466       <td>56.5658301822</td>
467       <td><font color="red"><b>Cache ratio should be at least 90%</b></font></td>
468     </tr>
469     <tr>
470       <td>InnoDB cache hit ratio</td>
471       <td>0</td>
472       <td><font color="red"><b>Cache ratio should be at least 90%</b></font></td>
473     </tr>
474     <tr>
475       <td>sql cache hit ratio</td>
476       <td>0</td>
477       <td>&nbsp;</td>
478     </tr>
479     <tr bgcolor="#f0f0f0">
480       <td colspan="3"><i>IO</i> &nbsp;</td>
481     </tr>
482     <tr>
483       <td>data reads</td>
484       <td>2622</td>
485       <td>Number of selects (Key_reads is not accurate)</td>
486     </tr>
487     <tr>
488       <td>data writes</td>
489       <td>2415.5</td>
490       <td>Number of inserts/updates/deletes * coef (Key_writes is not
491 accurate)</td>
492     </tr>
493     <tr bgcolor="#f0f0f0">
494       <td colspan="3"><i>Data Cache</i> &nbsp;</td>
495     </tr>
496     <tr>
497       <td>MyISAM data cache size</td>
498       <td>512K</td>
499       <td>&nbsp;</td>
500     </tr>
501     <tr>
502       <td>BDB data cache size</td>
503       <td>8388600</td>
504       <td>&nbsp;</td>
505     </tr>
506     <tr>
507       <td>InnoDB data cache size</td>
508       <td>8M</td>
509       <td>&nbsp;</td>
510     </tr>
511     <tr bgcolor="#f0f0f0">
512       <td colspan="3"><i>Memory Pools</i> &nbsp;</td>
513     </tr>
514     <tr>
515       <td>read buffer size</td>
516       <td>131072</td>
517       <td>(per session)</td>
518     </tr>
519     <tr>
520       <td>sort buffer size</td>
521       <td>65528</td>
522       <td>Size of sort buffer (per session)</td>
523     </tr>
524     <tr>
525       <td>table cache</td>
526       <td>4</td>
527       <td>Number of tables to keep open</td>
528     </tr>
529     <tr bgcolor="#f0f0f0">
530       <td colspan="3"><i>Connections</i> &nbsp;</td>
531     </tr>
532     <tr>
533       <td>current connections</td>
534       <td>3</td>
535       <td>&nbsp;</td>
536     </tr>
537     <tr>
538       <td>max connections</td>
539       <td>100</td>
540       <td>&nbsp;</td>
541     </tr>
542   </tbody>
543 </table>
544 <p>&nbsp;</p>
545 <p><a name="mssql" id="mssql"></a></p>
546 <table bgcolor="white" border="1">
547   <tbody>
548     <tr>
549       <td colspan="3">
550       <h3>mssql</h3>
551       </td>
552     </tr>
553     <tr>
554       <td><b>Parameter</b></td>
555       <td><b>Value</b></td>
556       <td><b>Description</b></td>
557     </tr>
558     <tr bgcolor="#f0f0f0">
559       <td colspan="3"><i>Ratios</i> &nbsp;</td>
560     </tr>
561     <tr>
562       <td>data cache hit ratio</td>
563       <td>99.9999694824</td>
564       <td>&nbsp;</td>
565     </tr>
566     <tr>
567       <td>prepared sql hit ratio</td>
568       <td>99.7738579828</td>
569       <td>&nbsp;</td>
570     </tr>
571     <tr>
572       <td>adhoc sql hit ratio</td>
573       <td>98.4540169133</td>
574       <td>&nbsp;</td>
575     </tr>
576     <tr bgcolor="#f0f0f0">
577       <td colspan="3"><i>IO</i> &nbsp;</td>
578     </tr>
579     <tr>
580       <td>data reads</td>
581       <td>2858</td>
582       <td>&nbsp; </td>
583     </tr>
584     <tr>
585       <td>data writes</td>
586       <td>1438</td>
587       <td>&nbsp; </td>
588     </tr>
589     <tr bgcolor="#f0f0f0">
590       <td colspan="3"><i>Data Cache</i> &nbsp;</td>
591     </tr>
592     <tr>
593       <td>data cache size</td>
594       <td>4362</td>
595       <td>in K</td>
596     </tr>
597     <tr bgcolor="#f0f0f0">
598       <td colspan="3"><i>Connections</i> &nbsp;</td>
599     </tr>
600     <tr>
601       <td>current connections</td>
602       <td>14</td>
603       <td>&nbsp;</td>
604     </tr>
605     <tr>
606       <td>max connections</td>
607       <td>32767</td>
608       <td>&nbsp;</td>
609     </tr>
610   </tbody>
611 </table>
612 <p>&nbsp;</p>
613 <p><a name="oci8" id="oci8"></a></p>
614 <table bgcolor="white" border="1">
615   <tbody>
616     <tr>
617       <td colspan="3">
618       <h3>oci8</h3>
619       </td>
620     </tr>
621     <tr>
622       <td><b>Parameter</b></td>
623       <td><b>Value</b></td>
624       <td><b>Description</b></td>
625     </tr>
626     <tr bgcolor="#f0f0f0">
627       <td colspan="3"><i>Ratios</i> &nbsp;</td>
628     </tr>
629     <tr>
630       <td>data cache hit ratio</td>
631       <td>96.98</td>
632       <td>&nbsp;</td>
633     </tr>
634     <tr>
635       <td>sql cache hit ratio</td>
636       <td>99.96</td>
637       <td>&nbsp;</td>
638     </tr>
639     <tr bgcolor="#f0f0f0">
640       <td colspan="3"><i>IO</i> &nbsp;</td>
641     </tr>
642     <tr>
643       <td>data reads</td>
644       <td>842938</td>
645       <td>&nbsp; </td>
646     </tr>
647     <tr>
648       <td>data writes</td>
649       <td>16852</td>
650       <td>&nbsp; </td>
651     </tr>
652     <tr bgcolor="#f0f0f0">
653       <td colspan="3"><i>Data Cache</i> &nbsp;</td>
654     </tr>
655     <tr>
656       <td>data cache buffers</td>
657       <td>3072</td>
658       <td>Number of cache buffers</td>
659     </tr>
660     <tr>
661       <td>data cache blocksize</td>
662       <td>8192</td>
663       <td>&nbsp;</td>
664     </tr>
665     <tr>
666       <td>data cache size</td>
667       <td>48M</td>
668       <td>shared_pool_size</td>
669     </tr>
670     <tr bgcolor="#f0f0f0">
671       <td colspan="3"><i>Memory Pools</i> &nbsp;</td>
672     </tr>
673     <tr>
674       <td>java pool size</td>
675       <td>0</td>
676       <td>java_pool_size</td>
677     </tr>
678     <tr>
679       <td>sort buffer size</td>
680       <td>512K</td>
681       <td>sort_area_size (per query)</td>
682     </tr>
683     <tr>
684       <td>user session buffer size</td>
685       <td>8M</td>
686       <td>large_pool_size</td>
687     </tr>
688     <tr bgcolor="#f0f0f0">
689       <td colspan="3"><i>Connections</i> &nbsp;</td>
690     </tr>
691     <tr>
692       <td>current connections</td>
693       <td>1</td>
694       <td>&nbsp;</td>
695     </tr>
696     <tr>
697       <td>max connections</td>
698       <td>170</td>
699       <td>&nbsp;</td>
700     </tr>
701     <tr>
702       <td>data cache utilization ratio</td>
703       <td>88.46</td>
704       <td>Percentage of data cache actually in use</td>
705     </tr>
706     <tr>
707       <td>user cache utilization ratio</td>
708       <td>91.76</td>
709       <td>Percentage of user cache (large_pool) actually in use</td>
710     </tr>
711     <tr>
712       <td>rollback segments</td>
713       <td>11</td>
714       <td>&nbsp;</td>
715     </tr>
716     <tr bgcolor="#f0f0f0">
717       <td colspan="3"><i>Transactions</i> &nbsp;</td>
718     </tr>
719     <tr>
720       <td>peak transactions</td>
721       <td>24</td>
722       <td>Taken from high-water-mark</td>
723     </tr>
724     <tr>
725       <td>max transactions</td>
726       <td>187</td>
727       <td>max transactions / rollback segments &lt; 3.5 (or
728 transactions_per_rollback_segment)</td>
729     </tr>
730     <tr bgcolor="#f0f0f0">
731       <td colspan="3"><i>Parameters</i> &nbsp;</td>
732     </tr>
733     <tr>
734       <td>cursor sharing</td>
735       <td>EXACT</td>
736       <td>Cursor reuse strategy. Recommended is FORCE (8i+) or SIMILAR
737 (9i+). See <a
738  href="http://www.praetoriate.com/oracle_tips_cursor_sharing.htm">cursor_sharing</a>.</td>
739     </tr>
740     <tr>
741       <td>index cache cost</td>
742       <td>0</td>
743       <td>% of indexed data blocks expected in the cache. Recommended
744 is 20-80. Default is 0. See <a
745  href="http://www.dba-oracle.com/oracle_tips_cbo_part1.htm">optimizer_index_caching</a>.</td>
746     </tr>
747     <tr>
748       <td>random page cost</td>
749       <td>100</td>
750       <td>Recommended is 10-50 for TP, and 50 for data warehouses.
751 Default is 100. See <a
752  href="http://www.dba-oracle.com/oracle_tips_cost_adj.htm">optimizer_index_cost_adj</a>.
753       </td>
754     </tr>
755   </tbody>
756 </table>
757 <h3>Suspicious SQL</h3>
758 <table bgcolor="white" border="1">
759   <tbody>
760     <tr>
761       <td><b>LOAD</b></td>
762       <td><b>EXECUTES</b></td>
763       <td><b>SQL_TEXT</b></td>
764     </tr>
765     <tr>
766       <td align="right"> .73%</td>
767       <td align="right">89</td>
768       <td>select u.name, o.name, t.spare1, t.pctfree$ from sys.obj$ o,
769 sys.user$ u, sys.tab$ t where (bitand(t.trigflag, 1048576) = 1048576)
770 and o.obj#=t.obj# and o.owner# = u.user# select i.obj#, i.flags,
771 u.name, o.name from sys.obj$ o, sys.user$ u, sys.ind$ i where
772 (bitand(i.flags, 256) = 256 or bitand(i.flags, 512) = 512) and
773 (not((i.type# = 9) and bitand(i.flags,8) = 8)) and o.obj#=i.obj# and
774 o.owner# = u.user# </td>
775     </tr>
776     <tr>
777       <td align="right"> .84%</td>
778       <td align="right">3</td>
779       <td>select /*+ RULE */ distinct tabs.table_name, tabs.owner ,
780 partitioned, iot_type , TEMPORARY, table_type, table_type_owner from
781 DBA_ALL_TABLES tabs where tabs.owner = :own </td>
782     </tr>
783     <tr>
784       <td align="right"> 3.95%</td>
785       <td align="right">6</td>
786       <td>SELECT round(count(1)*avg(buf.block_size)/1048576) FROM
787 DBA_OBJECTS obj, V$BH bh, dba_segments seg, v$buffer_pool buf WHERE
788 obj.object_id = bh.objd AND obj.owner != 'SYS' and obj.owner =
789 seg.owner and obj.object_name = seg.segment_name and obj.object_type =
790 seg.segment_type and seg.buffer_pool = buf.name and buf.name =
791 'DEFAULT' </td>
792     </tr>
793     <tr>
794       <td align="right"> 4.50%</td>
795       <td align="right">6</td>
796       <td>SELECT round(count(1)*avg(tsp.block_size)/1048576) FROM
797 DBA_OBJECTS obj, V$BH bh, dba_segments seg, dba_tablespaces tsp WHERE
798 obj.object_id = bh.objd AND obj.owner != 'SYS' and obj.owner =
799 seg.owner and obj.object_name = seg.segment_name and obj.object_type =
800 seg.segment_type and seg.tablespace_name = tsp.tablespace_name </td>
801     </tr>
802     <tr>
803       <td align="right">57.34%</td>
804       <td align="right">9267</td>
805       <td>select t.schema, t.name, t.flags, q.name from
806 system.aq$_queue_tables t, sys.aq$_queue_table_affinities aft,
807 system.aq$_queues q where aft.table_objno = t.objno and
808 aft.owner_instance = :1 and q.table_objno = t.objno and q.usage = 0 and
809 bitand(t.flags, 4+16+32+64+128+256) = 0 for update of t.name,
810 aft.table_objno skip locked </td>
811     </tr>
812   </tbody>
813 </table>
814 <h3>Expensive SQL</h3>
815 <table bgcolor="white" border="1">
816   <tbody>
817     <tr>
818       <td><b>LOAD</b></td>
819       <td><b>EXECUTES</b></td>
820       <td><b>SQL_TEXT</b></td>
821     </tr>
822     <tr>
823       <td align="right"> 5.24%</td>
824       <td align="right">1</td>
825       <td>select round(sum(bytes)/1048576) from dba_segments </td>
826     </tr>
827     <tr>
828       <td align="right"> 6.89%</td>
829       <td align="right">6</td>
830       <td>SELECT round(count(1)*avg(buf.block_size)/1048576) FROM
831 DBA_OBJECTS obj, V$BH bh, dba_segments seg, v$buffer_pool buf WHERE
832 obj.object_id = bh.objd AND obj.owner != 'SYS' and obj.owner =
833 seg.owner and obj.object_name = seg.segment_name and obj.object_type =
834 seg.segment_type and seg.buffer_pool = buf.name and buf.name =
835 'DEFAULT' </td>
836     </tr>
837     <tr>
838       <td align="right"> 7.85%</td>
839       <td align="right">6</td>
840       <td>SELECT round(count(1)*avg(tsp.block_size)/1048576) FROM
841 DBA_OBJECTS obj, V$BH bh, dba_segments seg, dba_tablespaces tsp WHERE
842 obj.object_id = bh.objd AND obj.owner != 'SYS' and obj.owner =
843 seg.owner and obj.object_name = seg.segment_name and obj.object_type =
844 seg.segment_type and seg.tablespace_name = tsp.tablespace_name </td>
845     </tr>
846     <tr>
847       <td align="right">33.69%</td>
848       <td align="right">89</td>
849       <td>select u.name, o.name, t.spare1, t.pctfree$ from sys.obj$ o,
850 sys.user$ u, sys.tab$ t where (bitand(t.trigflag, 1048576) = 1048576)
851 and o.obj#=t.obj# and o.owner# = u.user# </td>
852     </tr>
853     <tr>
854       <td align="right">36.44%</td>
855       <td align="right">89</td>
856       <td>select i.obj#, i.flags, u.name, o.name from sys.obj$ o,
857 sys.user$ u, sys.ind$ i where (bitand(i.flags, 256) = 256 or
858 bitand(i.flags, 512) = 512) and (not((i.type# = 9) and
859 bitand(i.flags,8) = 8)) and o.obj#=i.obj# and o.owner# = u.user# </td>
860     </tr>
861   </tbody>
862 </table>
863 <p><a name="postgres" id="postgres"></a></p>
864 <table bgcolor="white" border="1">
865   <tbody>
866     <tr>
867       <td colspan="3">
868       <h3>postgres7</h3>
869       </td>
870     </tr>
871     <tr>
872       <td><b>Parameter</b></td>
873       <td><b>Value</b></td>
874       <td><b>Description</b></td>
875     </tr>
876     <tr bgcolor="#f0f0f0">
877       <td colspan="3"><i>Ratios</i> &nbsp;</td>
878     </tr>
879     <tr>
880       <td>statistics collector</td>
881       <td>FALSE</td>
882       <td>Must be set to TRUE to enable hit ratio statistics (<i>stats_start_collector</i>,<i>stats_row_level</i>
883 and <i>stats_block_level</i> must be set to true in postgresql.conf)</td>
884     </tr>
885     <tr>
886       <td>data cache hit ratio</td>
887       <td>99.9666031916603</td>
888       <td>&nbsp;</td>
889     </tr>
890     <tr bgcolor="#f0f0f0">
891       <td colspan="3"><i>IO</i> &nbsp;</td>
892     </tr>
893     <tr>
894       <td>data reads</td>
895       <td>15</td>
896       <td>&nbsp; </td>
897     </tr>
898     <tr>
899       <td>data writes</td>
900       <td>0.000000000000000000</td>
901       <td>Count of inserts/updates/deletes * coef</td>
902     </tr>
903     <tr bgcolor="#f0f0f0">
904       <td colspan="3"><i>Data Cache</i> &nbsp;</td>
905     </tr>
906     <tr>
907       <td>data cache buffers</td>
908       <td>1280</td>
909       <td>Number of cache buffers. <a
910  href="http://www.varlena.com/GeneralBits/Tidbits/perf.html#basic">Tuning</a></td>
911     </tr>
912     <tr>
913       <td>cache blocksize</td>
914       <td>8192</td>
915       <td>(estimate)</td>
916     </tr>
917     <tr>
918       <td>data cache size</td>
919       <td>10M</td>
920       <td>&nbsp;</td>
921     </tr>
922     <tr>
923       <td>operating system cache size</td>
924       <td>80000K</td>
925       <td>(effective cache size)</td>
926     </tr>
927     <tr bgcolor="#f0f0f0">
928       <td colspan="3"><i>Memory Pools</i> &nbsp;</td>
929     </tr>
930     <tr>
931       <td>sort buffer size</td>
932       <td>1M</td>
933       <td>Size of sort buffer (per query)</td>
934     </tr>
935     <tr bgcolor="#f0f0f0">
936       <td colspan="3"><i>Connections</i> &nbsp;</td>
937     </tr>
938     <tr>
939       <td>current connections</td>
940       <td>13</td>
941       <td>&nbsp;</td>
942     </tr>
943     <tr>
944       <td>max connections</td>
945       <td>32</td>
946       <td>&nbsp;</td>
947     </tr>
948     <tr bgcolor="#f0f0f0">
949       <td colspan="3"><i>Parameters</i> &nbsp;</td>
950     </tr>
951     <tr>
952       <td>rollback buffers</td>
953       <td>8</td>
954       <td>WAL buffers</td>
955     </tr>
956     <tr>
957       <td>random page cost</td>
958       <td>4</td>
959       <td>Cost of doing a seek (default=4). See <a
960  href="http://www.varlena.com/GeneralBits/Tidbits/perf.html#less">random_page_cost</a></td>
961     </tr>
962   </tbody>
963 </table>
964 </body>
965 </html>