ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzajq_5.4.0.1/rzajqdisplayplancache.htm

186 lines
12 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="reference" />
<meta name="DC.Title" content="Viewing the plan cache with iSeries Navigator" />
<meta name="abstract" content="The Plan Cache contains a wealth of information about the SQE queries being run through the database. Its contents are viewable through the iSeries Navigator GUI interface." />
<meta name="description" content="The Plan Cache contains a wealth of information about the SQE queries being run through the database. Its contents are viewable through the iSeries Navigator GUI interface." />
<meta name="DC.Relation" scheme="URI" content="queryopt.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajqcache.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rzajqdisplayplancache" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Viewing the plan cache with iSeries Navigator</title>
</head>
<body id="rzajqdisplayplancache"><a name="rzajqdisplayplancache"><!-- --></a>
<img src="./delta.gif" alt="Start of change" /><!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Viewing the plan cache with iSeries™ Navigator</h1>
<div><p>The Plan Cache contains a wealth of information about the SQE queries
being run through the database. Its contents are viewable through the iSeries
Navigator GUI interface.</p>
<div class="section"><p>This Plan Cache interface provides a window into the database
query operations on the system. The interface to the Plan Cache resides under
the <span class="menucascade"><span class="uicontrol">iSeries Navigator</span> &gt; <span class="uicontrol">system
name</span> &gt; <span class="uicontrol">Database</span></span>.</p>
</div>
<div class="section"><img src="rzajq558.gif" alt="iSeries Navigator - SQL Plan Cache&#xA;Snapshots" /></div>
<div class="section"><p>Clicking the SQL Plan Cache folder shows a list of any snapshots
gathered so far. A snapshot is a database monitor file generated from the
plan cache and can be treated very much the same as the SQL Performance Monitors
list. The same analysis capability exists for snapshots as exists for traditional
SQL performance monitors. </p>
<p>By right-clicking the SQL Plan Cache icon,
a series of options are shown which allow different views of current plan
cache of the database. The <span class="menucascade"><span class="uicontrol">SQL Plan Cache</span> &gt; <span class="uicontrol">Show Statements</span></span> option brings up a screen
with filtering capability. This screen provides a direct view of the current
plan cache on the system. </p>
</div>
<div class="section"><img src="rzajq559.gif" alt="iSeries Navigator - SQL Plan Cache&#xA;statements" /></div>
<div class="section"><p>Note that the retrieve action needs to be performed (pushed) to
fill the display. The information shown shows the SQL query text, the last
time the query was run, the most expensive single instance run of the query,
total processing time consumed by the query, total number of times the query
has been run and information about the user and job that first created the
plan entry. It also shows how many times (if any) that the database engine
was able to reuse the results of a prior run of the query to avoid rerunning
the entire query.</p>
<p>The screen also provides filtering options which allow
the user to more quickly isolate specific criteria of interest. No filters
are required to be specified (the default), though adding filtering will shorten
the time it takes to show the results. The list of queries that is returned
is ordered by default so that those consuming the most processing time are
shown at the top. You can reorder the results by clicking on the column heading
for which you want the list ordered. Repeated clicking toggles the order from
ascending to descending. When an individual entry is chosen, more detailed
information about that entry can be seen. <strong>Show Longest Runs</strong> shows details
of up to ten of the longest running instances of that query. <strong>Run Visual
Explain</strong> can also be performed against the chosen query to show the details
of the query plan. Finally, if one or more entries are highlighted, a snapshot
(database performance monitor file) for those selected entries can be generated.</p>
<p>The
information presented can be used in multiple ways to help with performance
tuning. For example, Visual Explain of key queries can be utilized to show
advice for creating an index to improve those queries. Alternatively, the
longest running information can be used to determine if the query is being
run during a heavy utilization period and can potentially be rescheduled to
a more opportune time.</p>
<p>One item to note is that the user and job name
information given for each entry is the user and job that initially caused
the creation of the cached entry (the user where full optimization took place).
This is not necessarily the same as the last user to run that query.</p>
<p>The
filtering options provide a way to focus in on a particular area of interest:</p>
<dl><dt class="dlterm">Minimum runtime for the longest execution</dt>
<dd>Filter to those queries with at least one long individual query instance
runtime</dd>
<dt class="dlterm">Queries run after this date and time</dt>
<dd>Filters to those queries that have been run recently</dd>
<dt class="dlterm">Top 'n' most frequently run queries</dt>
<dd>Finds those queries run most often.</dd>
<dt class="dlterm">Top 'n' queries with the largest total accumulated runtime</dt>
<dd>Shows the top resource consumers. This equates to the first n entries
shown by default when no filtering is given. Specifying a value for n improves
the performance of getting the first screen of entries, though the total entries
displayed is limited to n.</dd>
<dt class="dlterm">Queries ever run by user</dt>
<dd>Provides a way to see the list of queries a particular user has run. Note
that if this filter is specified, the user and job name information shown
in the resulting entries still reflect the originator of the cached entry,
which is not necessarily the same as the user specified on the filter.</dd>
<dt class="dlterm">Queries currently active</dt>
<dd>Shows the list of cached entries associated with queries that are still
running or are in pseudo close mode. As with the user filtering, the user
and job name information shown in the resulting entries still reflects the
originator of the cached entry, which is not necessarily the same as the user
currently running the query (there may be multiple users running the query). <div class="note"><span class="notetitle">Note:</span> Current
SQL for a job (right-click the Database icon) is an alternative for the viewing
a particular job's active query.</div>
</dd>
<dt class="dlterm">Queries with index advised</dt>
<dd>Limits the list to those queries where an index was advised by the optimizer
to improve performance.</dd>
<dt class="dlterm">Queries with statistics advised</dt>
<dd>Limits the list to those queries where a statistic not yet gathered might
have been useful to the optimizer if it was collected. The optimizer automatically
gathers these statistics in the background, so this option is normally not
that interesting unless, for whatever reason, you want to control the statistics
gathering yourself.</dd>
<dt class="dlterm">Include queries initiated by the operating system</dt>
<dd>includes into the list the 'hidden' queries initiated by the database
itself behind the scenes to process a request. By default the list only includes
user initiated queries.</dd>
<dt class="dlterm">Queries that use or reference these objects</dt>
<dd>Provides a way to limit the entries to those that referenced or use the
table(s) or index(s) specified.</dd>
<dt class="dlterm">SQL statement contains</dt>
<dd>Provides a wildcard search capability on the SQL text itself. It is useful
for finding particular types of queries. For example, queries with a FETCH
FIRST clause can be found by specifying fetch. The search is case insensitive
for ease of use. For example, the string 'FETCH' will find the same entries
as the search string 'fetch'.</dd>
</dl>
<p>Multiple filter options can be specified. Note that in a
multi-filter case, the candidate entries for each filter are computed independently
and only those entries that are present in all the candidate lists are shown.
So, for example, if you specified options <strong>Top 'n' most frequently run queries</strong> and <strong>Queries
ever run by user</strong>, you will be shown those most-run entries in the cache
that happen to have been run at some point by the specified user. You will
not necessarily be shown the most frequently run queries run by the user (unless
those queries also happen to be the most frequently run queries in the entire
cache). </p>
<p>The <span class="menucascade"><span class="uicontrol">SQL Plan Cache</span> &gt; <span class="uicontrol">Properties</span></span> option shows high level information about the cache, including
for example, cache size, number of plans, number of full open and pseudo opens
that have occurred.</p>
</div>
<div class="section"><img src="rzajq560.gif" alt="iSeries Navigator - SQL Plan Cache&#xA;Properties" /></div>
<div class="section"><p>This information can be used to view overall database activity.
If tracked over time, it provides trends to help you better understand the
database utilization peaks and valleys throughout the day and week.</p>
<p>The <span class="menucascade"><span class="uicontrol">New</span> &gt; <span class="uicontrol">Snapshot</span></span> option
allows for the creation of a snapshot from the plan cache. Unlike the snapshot
option under Show Statements, it allows you to create a snapshot without having
to first view the queries. </p>
</div>
<div class="section"><img src="rzajq561.gif" alt="" /></div>
<div class="section"><p>The same filtering options are provided here as on the Show Statements
screen.</p>
<p>The stored procedure, qsys2.dump_plan_cache, provides
the simplest way to create a database monitor file output (snapshot) from
the plan cache. The dump_plan_cache procedure takes two parameters, library
name and file name, for identifying the resulting database monitor file. If
the file does not exist, it is created. For example, to dump the plan cache
to a database performance monitor file in library QGPL:</p>
<pre><strong>CALL</strong> qsys2.dump_plan_cache('QGPL','SNAPSHOT1');</pre>
</div>
<div class="section"><p>Note that the plan cache is an actively changing cache. Therefore,
it is important to realize that it contains timely information. If information
over long periods of time is of interest, consider implementing a method of
performing periodic snapshots of the plan cache to capture trends and heavy
usage periods. The APIs described above, used in conjunction with job scheduling
(for example), can be used to programmatically perform periodic snapshots.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="queryopt.htm" title="Query optimization is an iterative process. You can gather performance information about your queries and control the processing of your queries.">Optimizing query performance using query optimization tools</a></div>
</div>
<div class="relconcepts"><strong>Related concepts</strong><br />
<div><a href="rzajqcache.htm" title="The Plan Cache is a repository that contains the access plans for queries that were optimized by SQE.">Plan Cache</a></div>
</div>
</div>
<img src="./deltaend.gif" alt="End of change" /></body>
</html>