CDR Module: Fix for CQM framework.
[openemr.git] / library / adodb / docs-perf.htm
bloba7883cdb67998e0e94135601c5db933f8db0cbc8
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
3 <html>
4 <head>
5 <title>ADOdb Performance Monitoring Library</title>
6 </head>
8 <body>
9 <h3>The ADOdb Performance Monitoring Library</h3>
10 <p>V4.20 22 Feb 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my)</p>
11 <p><font size="1">This software is dual licensed using BSD-Style and LGPL. This
12 means you can use it in compiled proprietary and commercial products.</font></p>
13 <p>Useful ADOdb links: <a href=http://php.weblogs.com/adodb?perf=1>Download</a> &nbsp; <a href=http://php.weblogs.com/adodb_manual?perf=1>Other Docs</a>
14 <h3>Introduction</h3>
15 <p>This module, part of the ADOdb package, provides both CLI and HTML interfaces
16 for viewing key performance indicators of your database. This is very useful
17 because web apps such as the popular phpMyAdmin currently do not provide effective
18 database health monitoring tools. The module provides the following:
19 <ul>
20 <li>A quick health check of your database server using <code>$perf->HealthCheck()</code>
21 or <code>$perf->HealthCheckCLI()</code>.
22 <li>User interface for performance monitoring, <code>$perf-&gt;UI()</code>.
23 This UI displays:
24 <ul>
25 <li>the health check, </li>
26 <li>all SQL logged and their query plans, </li>
27 <li>a list of all tables in the current database</li>
28 <li>an interface to continiously poll the server for key performance indicators
29 such as CPU, Hit Ratio, Disk I/O</li>
30 <li>a form where you can enter and run SQL interactively.</li>
31 </ul>
32 <li>Gives you an API to build database monitoring tools for a server farm, for
33 example calling <code>$perf->DBParameter('data cache hit ratio')</code> returns
34 this very important statistic in a database independant manner.
35 </ul>
36 <p>ADOdb also has the ability to log all SQL executed, using <a href=docs-adodb.htm#logsql>LogSQL</a>.
37 All SQL logged can be analyzed through the performance monitor <a href=#ui>UI</a>.
38 In the <i>View SQL</i> mode, we categorize the SQL into 3 types:
39 <ul>
40 <li><b>Suspicious SQL</b>: queries with high average execution times, and are potential
41 candidates for rewriting</li>
42 <li><b>Expensive SQL</b>: queries with high total execution times (#executions * avg
43 execution time). Optimizing these queries will reduce your database server
44 load.</li>
45 <li><b>Invalid SQL</b>: queries that generate errors.</li>
46 </ul>
47 <p>Each query is hyperlinked to a description of the query plan, and every PHP
48 script that executed that query is also shown.</p>
49 <p>Please note that the information presented is a very basic database health
50 check, and does not provide a complete overview of database performance. Although
51 some attempt has been made to make it work across multiple databases in the
52 same way, it is impossible to do so. For the health check, we do try to display
53 the following key database parameters for all drivers:</p>
54 <ul>
55 <li><b>data cache size</b> - The amount of memory allocated to the cache.</li>
56 <li><b>data cache hit ratio</b> - A measure of how effective the cache is, as a percentage.
57 The higher, the better.</li>
58 <li><b>current connections</b> - The number of sessions currently connected to the
59 database. </li>
60 </ul>
61 <p>You will need to connect to the database as an administrator to view most of
62 the parameters. </p>
63 <p>Code improvements as very welcome, particularly adding new database parameters
64 and automated tuning hints.</p><a name=usage></a>
65 <h3>Usage</h3>
66 <p>Currently, the following drivers: <em>mysql</em>, <em>postgres</em>, <em>oci8</em>,
67 <em>mssql</em>, <i>informix</i> and <em>db2</em> are supported. To create a
68 new performance monitor, call NewPerfMonitor( ) as demonstrated below: </p>
69 <pre>
70 &lt;?php
71 include_once('adodb.inc.php');
72 session_start(); <font color="#006600"># session variables required for monitoring</font>
73 $conn = ADONewConnection($driver);
74 $conn-&gt;Connect($server,$user,$pwd,$db);
75 $perf =&amp; NewPerfMonitor($conn);
76 $perf-&gt;UI($pollsecs=5);<font color="#006600"></font>
78 </pre>
79 <p>It is also possible to retrieve a single database parameter:</p>
80 <pre>$size = $perf->DBParameter('data cache size');
81 </pre>
82 <p>
83 Thx to Fernando Ortiz for the informix module.
84 <h3>Methods</h3><a name=ui></a>
85 <p><font face="Courier New, Courier, mono">function <b>UI($pollsecs=5)</b></font></p>
86 <p>Creates a web-based user interface for performance monitoring. When you click on Poll,
87 server statistics will be displayed every $pollsecs seconds. See <a href="#usage">Usage</a>
88 above.
89 <p>Since 4.11, we allow users to enter and run SQL interactively via the "Run SQL" link. To disable
90 this for security reasons, set this constant before calling $perf->UI().
91 <p>
92 <pre>define('ADODB_PERF_NO_RUN_SQL',1);</pre>
94 <p>Sample output follows below:</p>
96 <table border=1 width=100% bgcolor=lightyellow><tr>
97 <td> <b><a href=http://php.weblogs.com/adodb?perf=1>ADOdb</a> Performance
98 Monitor</b> for localhost, db=test<br>
99 <font size=-1>PostgreSQL 7.3.2 on i686-pc-cygwin, compiled by GCC gcc (GCC)
100 3.2 20020927 (prerelease)</font></tr>
101 <tr><td>
102 <a href=#>Performance Stats</a> &nbsp; <a href=#>View SQL</a>
103 &nbsp; <a href=#>View Tables</a> &nbsp; <a href=#>Poll Stats</a></tr></table><table border=1 bgcolor=white><tr><td colspan=3><h3>postgres7</h3></td></tr><tr><td><b>Parameter</b></td><td><b>Value</b></td><td><b>Description</b></td></tr><tr bgcolor=#F0F0F0><td colspan=3><i>Ratios</i> &nbsp;</td></tr><tr><td>statistics collector</td><td>TRUE</td><td>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)</td></tr>
104 <tr><td>data cache hit ratio</td><td>99.7967555299239</td><td>&nbsp;</td></tr>
105 <tr bgcolor=#F0F0F0><td colspan=3><i>IO</i> &nbsp;</td></tr><tr><td>data reads</td><td>125</td><td>&nbsp; </td></tr>
106 <tr><td>data writes</td><td>21.78125000000000000</td><td>Count of inserts/updates/deletes * coef</td></tr>
107 <tr bgcolor=#F0F0F0><td colspan=3><i>Data Cache</i> &nbsp;</td></tr><tr><td>data cache buffers</td><td>640</td><td>Number of cache buffers. <a href=http://www.varlena.com/GeneralBits/Tidbits/perf.html#basic>Tuning</a></td></tr>
108 <tr><td>cache blocksize</td><td>8192</td><td>(estimate)</td></tr>
109 <tr><td>data cache size</td><td>5M</td><td>&nbsp;</td></tr>
110 <tr><td>operating system cache size</td><td>80M</td><td>(effective cache size)</td></tr>
111 <tr bgcolor=#F0F0F0><td colspan=3><i>Memory Usage</i> &nbsp;</td></tr><tr><td>sort buffer size</td><td>1M</td><td>Size of sort buffer (per query)</td></tr>
112 <tr bgcolor=#F0F0F0><td colspan=3><i>Connections</i> &nbsp;</td></tr><tr><td>current connections</td><td>0</td><td>&nbsp;</td></tr>
113 <tr><td>max connections</td><td>32</td><td>&nbsp;</td></tr>
114 <tr bgcolor=#F0F0F0><td colspan=3><i>Parameters</i> &nbsp;</td></tr><tr><td>rollback buffers</td><td>8</td><td>WAL buffers</td></tr>
115 <tr><td>random page cost</td><td>4</td><td>Cost of doing a seek (default=4). See <a href=http://www.varlena.com/GeneralBits/Tidbits/perf.html#less>random_page_cost</a></td></tr>
116 </table>
117 <p><font face="Courier New, Courier, mono">function <b>HealthCheck</b>()</font></p>
118 <p>Returns database health check parameters as a HTML table. You will need to
119 echo or print the output of this function,</p>
120 <p><font face="Courier New, Courier, mono">function <b>HealthCheckCLI</b>()</font></p>
121 <p>Returns database health check parameters formatted for a command line interface.
122 You will need to echo or print the output of this function. Sample output for
123 mysql:</p>
124 <pre>
125 -- Ratios --
126 MyISAM cache hit ratio => 56.5635738832
127 InnoDB cache hit ratio => 0
128 sql cache hit ratio => 0
129 -- IO --
130 data reads => 2622
131 data writes => 2415.5
132 -- Data Cache --
133 MyISAM data cache size => 512K
134 BDB data cache size => 8388600
135 InnoDB data cache size => 8M
136 -- Memory Pools --
137 read buffer size => 131072
138 sort buffer size => 65528
139 table cache => 4
140 -- Connections --
141 current connections => 3
142 max connections => 100</pre>
143 <p><font face="Courier New, Courier, mono">function <b>Poll</b>($pollSecs=5)
144 </font>
145 <p> Run in infinite loop, displaying the following information every $pollSecs.
146 This will not work properly if output buffering is enabled.
147 In the example below, $pollSecs=3:
148 <pre>
149 Accumulating statistics...
150 Time WS-CPU% Hit% Sess Reads/s Writes/s
151 11:08:30 0.7 56.56 1 0.0000 0.0000
152 11:08:33 1.8 56.56 2 0.0000 0.0000
153 11:08:36 11.1 56.55 3 2.5000 0.0000
154 11:08:39 9.8 56.55 2 3.1121 0.0000
155 11:08:42 2.8 56.55 1 0.0000 0.0000
156 11:08:45 7.4 56.55 2 0.0000 1.5000
157 </pre>
158 <p><b>WS-CPU%</b> is the Web Server CPU load of the server that PHP is running
159 from (eg. the database client), and not the database. The <b>Hit%</b> is the
160 data cache hit ratio. <b>Sess</b> is the current number of sessions connected
161 to the database. If you are using persistent connections, this should not change
162 much. The <b>Reads/s</b> and <b>Writes/s</b> are synthetic values to give the
163 viewer a rough guide to I/O, and are not to be taken literally.
164 <p><font face="Courier New, Courier, mono">function <b>SuspiciousSQL</b>($numsql=10)</font></p>
165 <p>Returns SQL which have high average execution times as a HTML table. Each sql statement
166 is hyperlinked to a new window which details the execution plan and the scripts that execute this SQL.
167 <p> The number of statements returned is determined by $numsql. Data is taken from the adodb_logsql table, where the sql statements are logged when
168 $connection->LogSQL(true) is enabled. The adodb_logsql table is populated using <a href=docs-adodb.htm#logsql>$conn->LogSQL</a>.
169 <p>For Oracle, Ixora Suspicious SQL returns a list of SQL statements that are most cache intensive as a HTML table.
170 These are data intensive SQL statements that could benefit most from tuning.
172 <p><font face="Courier New, Courier, mono">function <b>ExpensiveSQL</b>($numsql=10)</font></p>
173 <p>Returns SQL whose total execution time (avg time * #executions) is high as a HTML table. Each sql statement
174 is hyperlinked to a new window which details the execution plan and the scripts that execute this SQL.
175 <p> The number of statements returned is determined by $numsql. Data is taken from the adodb_logsql table, where the sql statements are logged when
176 $connection->LogSQL(true) is enabled. The adodb_logsql table is populated using <a href=docs-adodb.htm#logsql>$conn->LogSQL</a>.
178 <p>For Oracle, Ixora Expensive SQL returns a list of SQL statements that are taking the most CPU load
179 when run.
180 <p><font face="Courier New, Courier, mono">function <b>InvalidSQL</b>($numsql=10)</font></p>
181 <p>Returns a list of invalid SQL as an HTML table.
182 <p>Data is taken from the adodb_logsql table, where the sql statements are logged when
183 $connection->LogSQL(true) is enabled.
184 <p><font face="Courier New, Courier, mono">function <b>Tables</b>($orderby=1)</font></p>
185 <p>Returns information on all tables in a database, with the first two fields
186 containing the table name and table size, the remaining fields depend on the
187 database driver. If $orderby is set to 1, it will sort by name. If $orderby
188 is set to 2, then it will sort by table size. Some database drivers (mssql and
189 mysql) will ignore the $orderby clause. For postgresql, the information is up-to-date
190 since the last <i>vacuum</i>. Not supported currently for db2.</p>
191 <h3>Raw Functions</h3>
192 <p>Raw functions return values without any formatting.</p>
193 <p><font face="Courier New, Courier, mono">function <b>DBParameter</b>($paramname)</font></p>
194 <p>Returns the value of a database parameter, such as $this-&gt;DBParameter(&quot;data
195 cache size&quot;).</p>
196 <p><font face="Courier New, Courier, mono">function <b>CPULoad</b>()</font></p>
197 <p>Returns the CPU load of the database client (NOT THE SERVER) as a percentage.
198 Only works for Linux and Windows. For Windows, WMI must be available.</p>
199 <h3>Format of $settings Property</h3>
200 <p> To create new database parameters, you need to understand $settings. The $settings
201 data structure is an associative array. Each element of the array defines a
202 database parameter. The key is the name of the database parameter. If no key is defined,
203 then it is assumed to be a section break, and the value is the name of the section break.
204 If this is too confusing, looking at the source code will help a lot!</p>
205 <p> Each database parameter is itself an array consisting of the following elements:</p>
206 <ol start="0">
207 <li> Category code, used to group related db parameters. If the category code is 'HIDE', then
208 the database parameter is not shown when HTML() is called. <br>
209 </li>
210 <li> either
211 <ol type="a">
212 <li>sql string to retrieve value, eg. "select value from v\$parameter where
213 name='db_block_size'", </li>
214 <li>array holding sql string and field to look for, e.g. array('show variables','table_cache');
215 optional 3rd parameter is the $rs-&gt;fields[$index] to use (otherwise
216 $index=1), and optional 4th parameter is a constant to multiply the result
217 with (typically 100 for percentage calculations),</li>
218 <li>a string prefixed by =, then a PHP method of the class is invoked, e.g.
219 to invoke $this->GetIndexValue(), set this array element to '=GetIndexValue',
220 <br>
221 </li>
222 </ol>
223 </li>
224 <li> Description of database parameter. If description begins with an =, then
225 it is interpreted as a method call, just as in (1c) above, taking one parameter,
226 the current value. E.g. '=GetIndexDescription' will invoke $this->GetIndexDescription($val).
227 This is useful for generating tuning suggestions. For an example, see WarnCacheRatio().</li>
228 </ol>
229 <p>Example from MySQL, table_cache database parameter:</p>
230 <pre>'table cache' =&gt; array('CACHE', # category code
231 array(&quot;show variables&quot;, 'table_cache'), # array (type 1b)
232 'Number of tables to keep open'), # description</pre>
233 <h3>Example Health Check Output</h3>
234 <p><a href="#db2">db2</a> <a href=#informix>informix</a> <a href="#mysql">mysql</a> <a href="#mssql">mssql</a>
235 <a href="#oci8">oci8</a> <a href="#postgres">postgres</a></p>
236 <p><a name=db2></a></p>
237 <table border=1 bgcolor=white>
238 <tr>
239 <td colspan=3> <h3>db2</h3></td>
240 </tr>
241 <tr>
242 <td><b>Parameter</b></td>
243 <td><b>Value</b></td>
244 <td><b>Description</b></td>
245 </tr>
246 <tr bgcolor=#F0F0F0>
247 <td colspan=3><i>Ratios</i> &nbsp;</td>
248 </tr>
249 <tr bgcolor=#FFFFFF>
250 <td>data cache hit ratio</td>
251 <td>0 &nbsp; </td>
252 <td>&nbsp;</td>
253 </tr>
254 <tr bgcolor=#F0F0F0>
255 <td colspan=3><i>Data Cache</i></td>
256 </tr>
257 <tr bgcolor=#FFFFFF>
258 <td>data cache buffers</td>
259 <td>250 &nbsp; </td>
260 <td>See <a href=http://www7b.boulder.ibm.com/dmdd/library/techarticle/anshum/0107anshum.html#bufferpoolsize>tuning
261 reference</a>.</td>
262 </tr>
263 <tr bgcolor=#FFFFFF>
264 <td>cache blocksize</td>
265 <td>4096 &nbsp; </td>
266 <td>&nbsp;</td>
267 </tr>
268 <tr bgcolor=#FFFFFF>
269 <td>data cache size</td>
270 <td>1000K &nbsp; </td>
271 <td>&nbsp;</td>
272 </tr>
273 <tr bgcolor=#F0F0F0>
274 <td colspan=3><i>Connections</i></td>
275 </tr>
276 <tr bgcolor=#FFFFFF>
277 <td>current connections</td>
278 <td>2 &nbsp; </td>
279 <td>&nbsp;</td>
280 </tr>
281 </table>
282 <p>&nbsp;<p>
283 <a name=informix></a>
284 <table border=1 bgcolor=white><tr><td
285 colspan=3><h3>informix</h3></td></tr><tr><td><b>Parameter</b></td><td><b>Val
286 ue</b></td><td><b>Description</b></td></tr><tr bgcolor=#F0F0F0><td
287 colspan=3><i>Ratios</i> &nbsp;</td></tr><tr><td>data cache hit
288 ratio</td><td>95.89</td><td>&nbsp;</td></tr>
289 <tr bgcolor=#F0F0F0><td colspan=3><i>IO</i> &nbsp;</td></tr><tr><td>data
290 reads</td><td>1883884</td><td>Page reads</td></tr>
291 <tr><td>data writes</td><td>1716724</td><td>Page writes</td></tr>
292 <tr bgcolor=#F0F0F0><td colspan=3><i>Connections</i>
293 &nbsp;</td></tr><tr><td>current connections</td><td>263.0</td><td>Number of
294 sessions</td></tr>
295 </table>
298 <p>&nbsp;</p>
299 <p><a name=mysql id="mysql"></a></p><table border=1 bgcolor=white><tr><td colspan=3><h3>mysql</h3></td></tr><tr><td><b>Parameter</b></td><td><b>Value</b></td><td><b>Description</b></td></tr><tr bgcolor=#F0F0F0><td colspan=3><i>Ratios</i> &nbsp;</td></tr><tr><td>MyISAM cache hit ratio</td><td>56.5658301822</td><td><font color=red><b>Cache ratio should be at least 90%</b></font></td></tr>
300 <tr><td>InnoDB cache hit ratio</td><td>0</td><td><font color=red><b>Cache ratio should be at least 90%</b></font></td></tr>
301 <tr><td>sql cache hit ratio</td><td>0</td><td>&nbsp;</td></tr>
302 <tr bgcolor=#F0F0F0><td colspan=3><i>IO</i> &nbsp;</td></tr><tr><td>data reads</td><td>2622</td><td>Number of selects (Key_reads is not accurate)</td></tr>
303 <tr><td>data writes</td><td>2415.5</td><td>Number of inserts/updates/deletes * coef (Key_writes is not accurate)</td></tr>
304 <tr bgcolor=#F0F0F0><td colspan=3><i>Data Cache</i> &nbsp;</td></tr><tr><td>MyISAM data cache size</td><td>512K</td><td>&nbsp;</td></tr>
305 <tr><td>BDB data cache size</td><td>8388600</td><td>&nbsp;</td></tr>
306 <tr><td>InnoDB data cache size</td><td>8M</td><td>&nbsp;</td></tr>
307 <tr bgcolor=#F0F0F0><td colspan=3><i>Memory Pools</i> &nbsp;</td></tr><tr><td>read buffer size</td><td>131072</td><td>(per session)</td></tr>
308 <tr><td>sort buffer size</td><td>65528</td><td>Size of sort buffer (per session)</td></tr>
309 <tr><td>table cache</td><td>4</td><td>Number of tables to keep open</td></tr>
310 <tr bgcolor=#F0F0F0><td colspan=3><i>Connections</i> &nbsp;</td></tr><tr><td>current connections</td><td>3</td><td>&nbsp;</td></tr>
311 <tr><td>max connections</td><td>100</td><td>&nbsp;</td></tr>
312 </table>
313 <p>&nbsp;</p>
314 <p><a name=mssql id="mssql"></a></p>
316 <table border=1 bgcolor=white><tr><td colspan=3><h3>mssql</h3></td></tr><tr><td><b>Parameter</b></td><td><b>Value</b></td><td><b>Description</b></td></tr><tr bgcolor=#F0F0F0><td colspan=3><i>Ratios</i> &nbsp;</td></tr><tr><td>data cache hit ratio</td><td>99.9999694824</td><td>&nbsp;</td></tr>
317 <tr><td>prepared sql hit ratio</td><td>99.7738579828</td><td>&nbsp;</td></tr>
318 <tr><td>adhoc sql hit ratio</td><td>98.4540169133</td><td>&nbsp;</td></tr>
319 <tr bgcolor=#F0F0F0><td colspan=3><i>IO</i> &nbsp;</td></tr><tr><td>data reads</td><td>2858</td><td>&nbsp; </td></tr>
320 <tr><td>data writes</td><td>1438</td><td>&nbsp; </td></tr>
321 <tr bgcolor=#F0F0F0><td colspan=3><i>Data Cache</i> &nbsp;</td></tr><tr><td>data cache size</td><td>4362</td><td>in K</td></tr>
322 <tr bgcolor=#F0F0F0><td colspan=3><i>Connections</i> &nbsp;</td></tr><tr><td>current connections</td><td>14</td><td>&nbsp;</td></tr>
323 <tr><td>max connections</td><td>32767</td><td>&nbsp;</td></tr>
324 </table>
326 <p>&nbsp;</p>
327 <p><a name=oci8 id="oci8"></a></p>
328 <table border=1 bgcolor=white><tr><td colspan=3><h3>oci8</h3></td></tr><tr><td><b>Parameter</b></td><td><b>Value</b></td><td><b>Description</b></td></tr><tr bgcolor=#F0F0F0><td colspan=3><i>Ratios</i> &nbsp;</td></tr><tr><td>data cache hit ratio</td><td>96.98</td><td>&nbsp;</td></tr>
329 <tr><td>sql cache hit ratio</td><td>99.96</td><td>&nbsp;</td></tr>
330 <tr bgcolor=#F0F0F0><td colspan=3><i>IO</i> &nbsp;</td></tr><tr><td>data reads</td><td>842938</td><td>&nbsp; </td></tr>
331 <tr><td>data writes</td><td>16852</td><td>&nbsp; </td></tr>
332 <tr bgcolor=#F0F0F0><td colspan=3><i>Data Cache</i> &nbsp;</td></tr><tr><td>data cache buffers</td><td>3072</td><td>Number of cache buffers</td></tr>
333 <tr><td>data cache blocksize</td><td>8192</td><td>&nbsp;</td></tr>
334 <tr><td>data cache size</td><td>48M</td><td>shared_pool_size</td></tr>
335 <tr bgcolor=#F0F0F0><td colspan=3><i>Memory Pools</i> &nbsp;</td></tr><tr><td>java pool size</td><td>0</td><td>java_pool_size</td></tr>
336 <tr><td>sort buffer size</td><td>512K</td><td>sort_area_size (per query)</td></tr>
337 <tr><td>user session buffer size</td><td>8M</td><td>large_pool_size</td></tr>
338 <tr bgcolor=#F0F0F0><td colspan=3><i>Connections</i> &nbsp;</td></tr><tr><td>current connections</td><td>1</td><td>&nbsp;</td></tr>
339 <tr><td>max connections</td><td>170</td><td>&nbsp;</td></tr>
340 <tr><td>data cache utilization ratio</td><td>88.46</td><td>Percentage of data cache actually in use</td></tr>
341 <tr><td>user cache utilization ratio</td><td>91.76</td><td>Percentage of user cache (large_pool) actually in use</td></tr>
342 <tr><td>rollback segments</td><td>11</td><td>&nbsp;</td></tr>
343 <tr bgcolor=#F0F0F0><td colspan=3><i>Transactions</i> &nbsp;</td></tr><tr><td>peak transactions</td><td>24</td><td>Taken from high-water-mark</td></tr>
344 <tr><td>max transactions</td><td>187</td><td>max transactions / rollback segments < 3.5 (or transactions_per_rollback_segment)</td></tr>
345 <tr bgcolor=#F0F0F0><td colspan=3><i>Parameters</i> &nbsp;</td></tr><tr><td>cursor sharing</td><td>EXACT</td><td>Cursor reuse strategy. Recommended is FORCE (8i+) or SIMILAR (9i+). See <a href=http://www.praetoriate.com/oracle_tips_cursor_sharing.htm>cursor_sharing</a>.</td></tr>
346 <tr><td>index cache cost</td><td>0</td><td>% of indexed data blocks expected in the cache.
347 Recommended is 20-80. Default is 0. See <a href=http://www.dba-oracle.com/oracle_tips_cbo_part1.htm>optimizer_index_caching</a>.</td></tr>
348 <tr><td>random page cost</td><td>100</td><td>Recommended is 10-50 for TP, and 50 for data warehouses. Default is 100. See <a href=http://www.dba-oracle.com/oracle_tips_cost_adj.htm>optimizer_index_cost_adj</a>. </td></tr>
349 </table>
350 <h3>Suspicious SQL</h3>
352 <table border=1 bgcolor=white><tr><td><b>LOAD</b></td><td><b>EXECUTES</b></td><td><b>SQL_TEXT</b></td></tr>
353 <tr><td align=right> .73%</td><td align=right>89</td><td>select u.name, o.name, t.spare1, t.pctfree$ from sys.obj$ o, sys.user$ u, sys.tab$ t where (bitand(t.trigflag, 1048576) = 1048576) and o.obj#=t.obj# and o.owner# = u.user# select i.obj#, i.flags, u.name, o.name from sys.obj$ o, sys.user$ u, sys.ind$ i where (bitand(i.flags, 256) = 256 or bitand(i.flags, 512) = 512) and (not((i.type# = 9) and bitand(i.flags,8) = 8)) and o.obj#=i.obj# and o.owner# = u.user# </td></tr>
354 <tr><td align=right> .84%</td><td align=right>3</td><td>select /*+ RULE */ distinct tabs.table_name, tabs.owner , partitioned, iot_type , TEMPORARY, table_type, table_type_owner from DBA_ALL_TABLES tabs where tabs.owner = :own </td></tr>
355 <tr><td align=right> 3.95%</td><td align=right>6</td><td>SELECT round(count(1)*avg(buf.block_size)/1048576) FROM DBA_OBJECTS obj, V$BH bh, dba_segments seg, v$buffer_pool buf WHERE obj.object_id = bh.objd AND obj.owner != 'SYS' and obj.owner = seg.owner and obj.object_name = seg.segment_name and obj.object_type = seg.segment_type and seg.buffer_pool = buf.name and buf.name = 'DEFAULT' </td></tr>
356 <tr><td align=right> 4.50%</td><td align=right>6</td><td>SELECT round(count(1)*avg(tsp.block_size)/1048576) FROM DBA_OBJECTS obj, V$BH bh, dba_segments seg, dba_tablespaces tsp WHERE obj.object_id = bh.objd AND obj.owner != 'SYS' and obj.owner = seg.owner and obj.object_name = seg.segment_name and obj.object_type = seg.segment_type and seg.tablespace_name = tsp.tablespace_name </td></tr>
357 <tr><td align=right>57.34%</td><td align=right>9267</td><td>select t.schema, t.name, t.flags, q.name from system.aq$_queue_tables t, sys.aq$_queue_table_affinities aft, system.aq$_queues q where aft.table_objno = t.objno and aft.owner_instance = :1 and q.table_objno = t.objno and q.usage = 0 and bitand(t.flags, 4+16+32+64+128+256) = 0 for update of t.name, aft.table_objno skip locked </td></tr></table>
359 <h3>Expensive SQL</h3>
361 <table border=1 bgcolor=white><tr><td><b>LOAD</b></td><td><b>EXECUTES</b></td><td><b>SQL_TEXT</b></td></tr>
362 <tr><td align=right> 5.24%</td><td align=right>1</td><td>select round(sum(bytes)/1048576) from dba_segments </td></tr>
363 <tr><td align=right> 6.89%</td><td align=right>6</td><td>SELECT round(count(1)*avg(buf.block_size)/1048576) FROM DBA_OBJECTS obj, V$BH bh, dba_segments seg, v$buffer_pool buf WHERE obj.object_id = bh.objd AND obj.owner != 'SYS' and obj.owner = seg.owner and obj.object_name = seg.segment_name and obj.object_type = seg.segment_type and seg.buffer_pool = buf.name and buf.name = 'DEFAULT' </td></tr>
364 <tr><td align=right> 7.85%</td><td align=right>6</td><td>SELECT round(count(1)*avg(tsp.block_size)/1048576) FROM DBA_OBJECTS obj, V$BH bh, dba_segments seg, dba_tablespaces tsp WHERE obj.object_id = bh.objd AND obj.owner != 'SYS' and obj.owner = seg.owner and obj.object_name = seg.segment_name and obj.object_type = seg.segment_type and seg.tablespace_name = tsp.tablespace_name </td></tr>
365 <tr><td align=right>33.69%</td><td align=right>89</td><td>select u.name, o.name, t.spare1, t.pctfree$ from sys.obj$ o, sys.user$ u, sys.tab$ t where (bitand(t.trigflag, 1048576) = 1048576) and o.obj#=t.obj# and o.owner# = u.user# </td></tr>
366 <tr><td align=right>36.44%</td><td align=right>89</td><td>select i.obj#, i.flags, u.name, o.name from sys.obj$ o, sys.user$ u, sys.ind$ i where (bitand(i.flags, 256) = 256 or bitand(i.flags, 512) = 512) and (not((i.type# = 9) and bitand(i.flags,8) = 8)) and o.obj#=i.obj# and o.owner# = u.user# </td></tr></table>
368 <p><a name=postgres id="postgres"></a></p>
370 <table border=1 bgcolor=white><tr><td colspan=3><h3>postgres7</h3></td></tr><tr><td><b>Parameter</b></td><td><b>Value</b></td><td><b>Description</b></td></tr><tr bgcolor=#F0F0F0><td colspan=3><i>Ratios</i> &nbsp;</td></tr><tr><td>statistics collector</td><td>FALSE</td><td>Must be set to 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)</td></tr>
371 <tr><td>data cache hit ratio</td><td>99.9666031916603</td><td>&nbsp;</td></tr>
372 <tr bgcolor=#F0F0F0><td colspan=3><i>IO</i> &nbsp;</td></tr><tr><td>data reads</td><td>15</td><td>&nbsp; </td></tr>
373 <tr><td>data writes</td><td>0.000000000000000000</td><td>Count of inserts/updates/deletes * coef</td></tr>
374 <tr bgcolor=#F0F0F0><td colspan=3><i>Data Cache</i> &nbsp;</td></tr><tr><td>data cache buffers</td><td>1280</td><td>Number of cache buffers. <a href=http://www.varlena.com/GeneralBits/Tidbits/perf.html#basic>Tuning</a></td></tr>
375 <tr><td>cache blocksize</td><td>8192</td><td>(estimate)</td></tr>
376 <tr><td>data cache size</td><td>10M</td><td>&nbsp;</td></tr>
377 <tr><td>operating system cache size</td><td>80000K</td><td>(effective cache size)</td></tr>
378 <tr bgcolor=#F0F0F0><td colspan=3><i>Memory Pools</i> &nbsp;</td></tr><tr><td>sort buffer size</td><td>1M</td><td>Size of sort buffer (per query)</td></tr>
379 <tr bgcolor=#F0F0F0><td colspan=3><i>Connections</i> &nbsp;</td></tr><tr><td>current connections</td><td>13</td><td>&nbsp;</td></tr>
380 <tr><td>max connections</td><td>32</td><td>&nbsp;</td></tr>
381 <tr bgcolor=#F0F0F0><td colspan=3><i>Parameters</i> &nbsp;</td></tr><tr><td>rollback buffers</td><td>8</td><td>WAL buffers</td></tr>
382 <tr><td>random page cost</td><td>4</td><td>Cost of doing a seek (default=4). See <a href=http://www.varlena.com/GeneralBits/Tidbits/perf.html#less>random_page_cost</a></td></tr>
383 </table>
385 </body>
386 </html>