2019.03.28
GATHER PLAN STATISTICS
目次
概要
GATHER_PLAN_STATISTICSヒントを使用すると、SQLの実行時にRow Source Operation情報を収集します。収集された情報は、DBMS_XPLAN.DISPLAY_CURSORプロシージャを使用して確認可能です。
使い方
GATHER_PLAN_STATISTICSヒントの使用方法は、次のとおりです。
SQL> select / * + gather_plan_statistics * / * from delete_test where id <1000; SQL> select * from table(dbms_xplan.display_cursor(null、null、「ALLSTATS LAST ')); - 10gR1で - SQL> select * from table(dbms_xplan.display_cursor(null、null、「RUNSTATS_LAST ')); - null、null値は、最も最近に実行されたクエリを意味します。もし、特定のクエリを指定したい場合は SQL IDとChild Numberを使用してください。 PLAN_TABLE_OUTPUT -------------------------------------------------- ------------------------------ SQL_ID 04zt89r2fw2uw、child number 0 ------------------------------------- select / * + gather_plan_statistics * / * from delete_test where id <1000 Plan hash value:1827500787 -------------------------------------------------- ---------------------------------------- | Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | -------------------------------------------------- ---------------------------------------- | 1 | TABLE ACCESS BY INDEX ROWID | DELETE_TEST | 1 | 1 | 1000 | 00:00:00.01 | 140 | | * 2 | INDEX RANGE SCAN | DELETE_TEST_IDX | 1 | 1 | 1000 | 00:00:00.01 | 70 | Predicate Information(identified by operation id): -------------------------------------------------- - 2 - access( "ID" <1000)
上記の情報では、次のような用語を理解する必要があります。
・E-Rows:Estimated Row数を意味します。 ・A-Rows:Actual Row数を意味します。E-RowsとA-Rowsが大きな違いが出たら、統計情報とCostの計算に 問題があることを暗示します。 ・A-Time:Actual Elapsed Timeを意味します。この時間は、情報収集によるOverheadを含んでいます。 ・Buffers:読んだBuffer数を意味します。 ・Starts:Row Source Operationを実行した回数を意味します。つまり、E-Rows* Startsの値をA-Rowsと 比較しなければなりません。
サポート
GATHER_PLAN_STATISTICSヒントは、Oracle10gからサポートされています。
例
使い方
Syntaxは以下の通りです。
procedure purge (name varchar2, flag char DEFAULT 'P', heaps number DEFAULT 1);
Parameterの意味は次のとおりです。
procedure purge (name varchar2, flag char DEFAULT 'P', heaps number DEFAULT 1); Explanation: Purge the named object or particular heap(s) of the object. Input arguments: name: The name of the object to purge. There are two kinds of objects: PL/SQL objects, triggers, sequences, types and Java objects which are specified by name, SQL cursor objects which are specified by a twopart number. The value for this identifier is the concatenation of the 'address' and 'hash_value' columns from the v$sqlarea view. flag: This is an optional parameter. If the parameter is not specified, the package assumes that the first parameter is the name of a package/procedure/function and will resolve the name. Otherwise, the parameter is a character string indicating what kind of object to purge the name identifies. The string is case insensitive. The possible values and the kinds of objects they indicate are given in the following table: Value Kind of Object to keep ----- ---------------------- P package/procedure/function Q sequence R trigger T type JS java source JC java class JR java resource JD java shared data C cursor heaps: heaps to purge. e.g if heap 0 and heap 6 are to be purged. 1 hex 0x41 => decimal 65. so specify heaps=>65. Default is 1 i.e heap 0 which means the whole object will be purged.
使い方は以下の通りです。
- 特定のSQL CursorをPurgeしようとする場合、 select address、hash_value from v$ sqlarea where sql_text like'....'; ADDRESS HASH_VALUE --------------------------- 2F4651EC3900782439 exec sys.dbms_shared_pool.purge(「2F4651EC.3900782439'、' C'); - Heap0のみPurgeする場合 exec sys.dbms_shared_pool.purge(「2F4651EC.3900782439'、' C'、1); - Heap6万Purgeする場合 exec sys.dbms_shared_pool.purge(「2F4651EC.3900782439'、' C'、64); - 特定のProcedureをPurgeしようとする場合、 exec sys.dbms_shared_pool.purge(「OWI.TEST_PROC'、' P ');
関連情報
1.BMS_STASパッケージ 2.Explain Plan 3.10046 Event
外部参照
1.http://jonathanlewis.wordpress.com/2006/11/09/dbms_xplan-in-10g 2.http://jonathanlewis.wordpress.com/2007/04/26/heisenberg/