Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
My sqlplus script xplan has been designed to dump, in a concise and complete text report, all the
informations that are needed to tune a SGA-resident SQL statement.
When tuning (or simply studying) a statement, one typically needs or eagerly wants:
the accessed tables definition (columns, indexes, partitions) and their CBO-related statistics
the text of referenced views, PL/SQL functions or packages (and sequences, evil triggers, etc)
its plan, and for every plan line, its performance measures (i.e. elapsed time, buffer gets, rows returned,
etc)
peeked bind values and types
instance and session parameters, and system statistics
wait event profile from ASH (Active Session History)
Christian Antognini
Connor McDonald
Jonathan Lewis
Julian Dyke
Oak Table
Steve Adams
Tom Kyte
All these informations are automatically dumped by xplan, sparing us from a lot of tedious and error-prone
work.
Wolfgang Breitling
You can identify the statement(s) you want in the report by matching a like-expression, or by sql_id,
hash_value, module, action, instance_id, parsing user, or a combination of them. E.g.:
SQL>@xplan "select%my_table%" "module=MY_MODULE,parsed_by=WEB_USER"
This dumps all select statements that reference my_table, issued by module MY_MODULE and parsed by
WEB_USER.
Please note that since xplan is a sqlplus script, you don't need to install anything anywhere - you just
need sqlplus and an account with the necessary privileges.
Chen Shapira
Christian Antognini
You can find more details in the main script (xplan.sql) header, and a report example below.
Coskan Gundogar
Report example
Doug Burns
Greg Rahn
A report example from Oracle 11g (from demo script xplan_showcase.sql) - comments in bold:
Iggy Fernandez
James Morle
Adrian Billington
Jonathan Lewis
Kevin Closson
Richard Foote
Riyaj Shamsudeen
--------------------------------------------|optimizer param name
|value
|
Tanel Poder
--------------------------------------------|parallel_query_mode
|
enabled |
Tom Kyte
|parallel_threads_per_cpu
|
2 |
Toon Koppelaars
|pga_aggregate_target
|
204800 KB |
|query_rewrite_enabled
|
true |
|query_rewrite_integrity
|
enforced |
|result_cache_mode
| order)MANUAL |
Blog Aggregators (alphabetical
|skip_unusable_indexes
|
true |
|sort_area_retained_size
|
0 |
|sort_area_size
|
65536 |
Coskan Gundogar's
|star_transformation_enabled |
false |
|statistics_level
Kurt Van Meerbeeck's
|
typical |
|total_cpu_count
|
2 |
|total_processor_group_count |
1 |
|transaction_isolation_level |read_commited |
|workarea_size_policy
|
auto |
---------------------------------------------
-------------------------------------------------|gv$sql statname
|total
|/exec
|
-------------------------------------------------|users_executing
|
0 |
.0 |
|application wait (usec) |
0 |
.0 |
|concurrency wait (usec) |
0 |
.0 |
|cluster
wait (usec) |
0 |
.0 |
|user io
wait (usec) |1,444,402 |1,444,402.0 |
|plsql exec wait (usec) |
11 |
11.0 |
|java exec wait (usec) |
0 |
.0 |
--------------------------------------------------
Statement text:
SELECT /*+ index(t,t_fbi) ordered use_nl(v) xplan_test_marker */ T.RR, PLSQL_FUNC(MAX(T.X)) FROM T, V WHERE UPPER(T.X) >= '0' AND T.X > :B1 AND V.RR
='x' GROUP BY T.RR ORDER BY T.RR
Names of non-table objects depended on (from v$object_dependency) - full definition at the bottom of the report:
- depends on view DELLERA.V
- depends on function DELLERA.PLSQL_FUNC
-------------------------------------------------------------------------------------------------------------------------------------------------------------|ColName
|Expression (full)
|
----------------------------------------------------------------------------------------------------------------------------|SYS_NC00004$|I:UPPER(TO_CHAR("X"))
|
|SYS_NC00005$|I:CASE "X" WHEN 0 THEN 'pippo' WHEN 1 THEN 'uuiio' WHEN 3 THEN 'uuciio' WHEN 4 THEN 'uuieio' ELSE 'pppppp' END|
----------------------------------------------------------------------------------------------------------------------------Accessed table CBO statistics (for partitions too):
------------------------------------------------------------------------------|Pid|Partition|num_rows|avg_row_len|sample_size|last_analyzed
|parallel |
------------------------------------------------------------------------------|
|
|
1000|
318|
1000|2012/08/22 16:18:38|
1|
| 1|P1
|
100|
316|
100|2012/08/22 16:18:38|
|
| 2|P2
|
100|
318|
100|2012/08/22 16:18:38|
|
| 3|POTHER
|
800|
318|
800|2012/08/22 16:18:38|
|
------------------------------------------------------------------------------Accessed table columns CBO statistics (for partitions too):
---------------------------------------------------------------------------------------------------------|ColName
|Partition|ndv |dens*#rows|num_nulls|#bkts|hist|avg_col_len|sample_size|last_analyzed
|
---------------------------------------------------------------------------------------------------------|X
|
|1,000|
1.0|
0| 254|HB |
4|
1,000|2012/08/25 11:38:24|
|PADDING
|
|1,000|
1.0|
0| 254|HB |
301|
1,000|2012/08/25 11:38:24|
|RR
|
|
1|
0.5|
0|
1|FREQ|
2|
1,000|2012/08/25 11:38:24|
|SYS_NC00004$|
|1,000|
1.0|
0| 254|HB |
4|
1,000|2012/08/25 11:38:24|
|SYS_NC00005$|
|
4|
0.5|
0|
4|FREQ|
7|
1,000|2012/08/25 11:38:24|
|X
|P1
| 100|
5.0|
0| 100|HB |
3|
100|2012/08/25 11:38:24|
|X
|P2
| 100|
5.0|
0| 100|HB |
4|
100|2012/08/25 11:38:24|
|X
|POTHER
| 800|
1.3|
0| 254|HB |
4|
800|2012/08/25 11:38:24|
|PADDING
|P1
| 100|
5.0|
0| 100|HB |
301|
100|2012/08/25 11:38:24|
|PADDING
|P2
| 100|
5.0|
0| 100|HB |
301|
100|2012/08/25 11:38:24|
|PADDING
|POTHER
| 800|
1.3|
0| 254|HB |
301|
800|2012/08/25 11:38:24|
|RR
|P1
|
1|
5.0|
0|
1|FREQ|
2|
100|2012/08/25 11:38:24|
|RR
|P2
|
1|
5.0|
0|
1|FREQ|
2|
100|2012/08/25 11:38:24|
|RR
|POTHER
|
1|
0.6|
0|
1|FREQ|
2|
800|2012/08/25 11:38:24|
|SYS_NC00004$|P1
| 100|
5.0|
0| 100|HB |
3|
100|2012/08/25 11:38:24|
|SYS_NC00004$|P2
| 100|
5.0|
0| 100|HB |
4|
100|2012/08/25 11:38:24|
|SYS_NC00004$|POTHER
| 800|
1.3|
0| 254|HB |
5|
800|2012/08/25 11:38:24|
|SYS_NC00005$|P1
|
4|
5.0|
0|
4|FREQ|
7|
100|2012/08/25 11:38:24|
|SYS_NC00005$|P2
|
1|
5.0|
0|
1|FREQ|
7|
100|2012/08/25 11:38:24|
|SYS_NC00005$|POTHER
|
1|
0.6|
0|
1|FREQ|
7|
800|2012/08/25 11:38:24|
---------------------------------------------------------------------------------------------------------Accessed table index(es) definitions and CBO statistics (for partitions too):
### index #1: DELLERA.T_FBI
on DELLERA.T ( X, SYS_NC00004$, PADDING )
NONUNIQUE FUNCTION-BASED B+TREE
LOCAL PARTITIONED BY RANGE ( X, PADDING )
--------------------------------------------------------------------------------------------------|Partition|distinct_keys|num_rows|blevel|leaf_blocks|cluf|sample_size|last_analyzed
|parallel|
--------------------------------------------------------------------------------------------------|
|
1,000|
1,000|
1|
47| 47|
1,000|2012/08/25 11:38:25|1
|
|P1
|
100|
100|
1|
5|
5|
100|2012/08/25 11:38:25|
|
|P2
|
100|
100|
1|
5|
5|
100|2012/08/25 11:38:25|
|
|POTHER
|
800|
800|
1|
37| 37|
800|2012/08/25 11:38:25|
|
--------------------------------------------------------------------------------------------------### index #2: DELLERA.T_FBI2
on DELLERA.T ( X, SYS_NC00005$ )
NONUNIQUE FUNCTION-BASED B+TREE
----------------------------------------------------------------------------------------|distinct_keys|num_rows|blevel|leaf_blocks|cluf|sample_size|last_analyzed
|parallel|
----------------------------------------------------------------------------------------|
1,000|
1,000|
1|
46| 47|
1,000|2012/08/25 11:38:25|1
|
----------------------------------------------------------------------------------------### index #3: DELLERA.T_IDX
on DELLERA.T ( PADDING, X )
NONUNIQUE B+TREE
LOCAL PARTITIONED BY RANGE ( X, PADDING )
--------------------------------------------------------------------------------------------------|Partition|distinct_keys|num_rows|blevel|leaf_blocks|cluf|sample_size|last_analyzed
|parallel|
--------------------------------------------------------------------------------------------------|
|
1,000|
1,000|
1|
47| 64|
1,000|2012/08/25 11:38:25|1
|
|P1
|
100|
100|
1|
5| 21|
100|2012/08/25 11:38:25|
|
|P2
|
100|
100|
1|
5|
5|
100|2012/08/25 11:38:25|
|
|POTHER
|
800|
800|
1|
37| 38|
800|2012/08/25 11:38:25|
|
--------------------------------------------------------------------------------------------------### index #4: DELLERA.T_PK
on DELLERA.T ( X, PADDING )
UNIQUE IOT - TOP
LOCAL PARTITIONED BY RANGE ( X, PADDING )
--------------------------------------------------------------------------------------------------|Partition|distinct_keys|num_rows|blevel|leaf_blocks|cluf|sample_size|last_analyzed
|parallel|
--------------------------------------------------------------------------------------------------|
|
1,000|
1,000|
1|
47|
0|
1,000|2012/08/25 11:38:25|1
|
|P1
|
100|
100|
1|
5|
0|
100|2012/08/25 11:38:25|
|
|P2
|
100|
100|
1|
5|
0|
100|2012/08/25 11:38:25|
|
|POTHER
|
800|
800|
1|
37|
0|
800|2012/08/25 11:38:25|
|
--------------------------------------------------------------------------------------------------### index #5: DELLERA.T_UQ_1
on DELLERA.T ( PADDING )
UNIQUE B+TREE
----------------------------------------------------------------------------------------|distinct_keys|num_rows|blevel|leaf_blocks|cluf|sample_size|last_analyzed
|parallel|
----------------------------------------------------------------------------------------|
1,000|
1,000|
1|
46| 231|
1,000|2012/08/25 11:38:25|1
|
----------------------------------------------------------------------------------------Definition of dependent objects (e.g. accessed views, packages, functions):
############################################# function DELLERA.PLSQL_FUNC ###
ASSOCIATED STATISTICS: default selectivity (.001) default cost (cpu=100 io=10 net=1)
function plsql_func (p varchar2)
return varchar2
is
begin
return p;
end plsql_func;
############################################# view DELLERA.V ###
view columns: #1 X(NUMBER),#2 PADDING(VARCHAR2),#3 RR(VARCHAR2)
select x, padding, rr
from t
where x > 0
Options and Statement text filter SQL-like expression summary:
OPTIONS: inst_id=1 plan_stats=last access_predicates=Y lines=150 ash_profile_mins=15 module= action= hash= sql_id= parsed_by= child_number=
dbms_xplan=N dbms_metadata=N plan_details=Y plan_env=Y tabinfos=Y objinfos=Y partinfos=Y self=Y order_by= numbers_with_comma=Y
spool_name=xplan_i1.lst spool_files=single
SQL_LIKE="%xplan_test_marker%"
Licence warning:
-- Warning: since ash_profile_mins > 0, you are using ASH/AWR; make sure you are licensed to use it.