Presentation is loading. Please wait.

Presentation is loading. Please wait.

© 2005 Julian Dyke juliandyke.com 1 V$SQL_PLAN  Introduced in Oracle 9.0.1  Shows actual execution plan in memory  Enhanced in Oracle 9.2 to include.

Similar presentations


Presentation on theme: "© 2005 Julian Dyke juliandyke.com 1 V$SQL_PLAN  Introduced in Oracle 9.0.1  Shows actual execution plan in memory  Enhanced in Oracle 9.2 to include."— Presentation transcript:

1 © 2005 Julian Dyke juliandyke.com 1 V$SQL_PLAN  Introduced in Oracle  Shows actual execution plan in memory  Enhanced in Oracle 9.2 to include  Access Predicates (Joins)  Filter Predicates  Related views include  V$SQL_PLAN_WORKAREA  V$SQL_PLAN_STATISTICS  V$SQL_PLAN_STATISTICS_ALL

2 © 2005 Julian Dyke juliandyke.com 2 V$SQL_PLAN ADDRESSRAW(4) HASH_VALUENUMBER CHILD_NUMBERNUMBER OPERATIONVARCHAR2(30) OPTIONSVARCHAR2(30) OBJECT_NODEVARCHAR2(10) OBJECT#NUMBER OBJECT_OWNERVARCHAR2(30) OBJECT_NAMEVARCHAR2(64) OPTIMIZERVARCHAR2(20) IDNUMBER PARENT_IDNUMBER DEPTHNUMBER POSITIONNUMBER COSTNUMBER CARDINALITYNUMBER BYTESNUMBER OTHER_TAGVARCHAR(35) PARTITION_STARTVARCHAR2(5) PARTITION_STOPVARCHAR2(5) PARTITION_IDNUMBER OTHERVARCHAR2(4000) DISTRIBUTIONVARCHAR2(20) CPU_COSTNUMBER IO_COSTNUMBER TEMP_SPACENUMBER ACCESS_PREDICATESVARCHAR2(4000) FILTER_PREDICATESVARCHAR2(4000) PROJECTIONVARCHAR2(4000) TIMENUMBER QBLOCK_NAMEVARCHAR2(31) REMARKSVARCHAR2(4000)

3 © 2005 Julian Dyke juliandyke.com 3 Optimizer Environment Variables  In Oracle 10.1 and above, optimizer environment variables are externalized at :  instance level - V$SYS_OPTIMIZER_ENV  session level - V$SES_OPTIMIZER_ENV  statement level - V$SQL_OPTIMIZER_ENV  Use the values in these views when determining why execution plans differ

4 © 2005 Julian Dyke juliandyke.com 4 Optimizer Environment Variables  Optimizer Environment Variable values reported by the dynamic performance views include: active_instance_countparallel_dml_mode bitmap_merge_area_sizeparallel_execution_enabled cpu_countparallel_query_mode cursor_sharingparallel_threads_per_cpu db_file_multiblock_read_countpga_aggregate_target hash_area_sizequery_rewrite_enabled optimizer_dynamic_samplingquery_rewrite_integrity optimizer_features_enableskip_unusable_indexes optimizer_index_cachingsort_area_retained_size optimizer_index_cost_adjsort_area_size optimizer_modestar_transformation_enabled optimizer_mode_hintedstatistics_level parallel_ddl_modeworkarea_size_policy

5 © 2005 Julian Dyke juliandyke.com 5 DBMS_XPLAN  Introduced in Oracle 9.2  Formats PLAN_TABLE contents generated by EXPLAIN PLAN SELECT * FROM TABLE (dbms_xplan.display);  DISPLAY function parameters include  TABLE_NAME – name of plan table  STATEMENT_ID – statement ID in plan table  FORMAT – as below ValueDescription BASICOperation ID, object name and operation/option only TYPICAL(Default) Most relevant information including partition pruning, parallelism and predicates where appropriate ALLAs TYPICAL plus parallel execution server statements SERIALAs TYPICAL without parallel execution server statements

6 © 2005 Julian Dyke juliandyke.com 6 DBMS_XPLAN  For example explain a query EXPLAIN PLAN FOR SET STATEMENT_ID = 'STATEMENT1' FOR SELECT t1.c2, t2.c2 FROM t1, t2 WHERE t1.c1 = t2.c1 AND t1.c2 = 10; SELECT * FROM TABLE ( dbms_xplan.display ('PLAN_TABLE','STATEMENT1') );  The plan table can be queried using

7 © 2005 Julian Dyke juliandyke.com 7 DBMS_XPLAN  Example output with predicates IdOperationNameRowsBytesCost 0SELECT STATEMENT * 1HASH JOIN * 2TABLE ACCESS FULLT TABLE ACCESS FULLT Predicate Information (identified by operation id): 1 - access("T1"."C1"="T2"."C1") 2 - filter("T1"."C2"=10)

8 © 2005 Julian Dyke juliandyke.com 8 DBMS_XPLAN  Parallel execution queries are automatically formatted e.g. EXPLAIN PLAN FOR SELECT /*+ ORDERED PARALLEL (t1 2) USE_MERGE (t1 t2) */ t1.c2, t2.c2 FROM t1, t2 WHERE t1.c1 = t2.c1 AND t1.c2 = 10; SELECT * FROM TABLE (dbms_xplan.display);  The plan table can be queried using

9 © 2005 Julian Dyke juliandyke.com 9 DBMS_XPLAN  Example output for parallel execution IdOperationNameRowsBytesCostTQIN-OUTPQ Distrib 0SELECT STATEMENT MERGE JOIN ,02P->SQC(RANDOM) 2SORT JOIN ,02PCWP * 3TABLE ACCESS FULLT ,01P->PHASH * 4SORT JOIN ,02PCWP 5TABLE ACCESS FULLT ,00S->PHASH Predicate Information (identified by operation id): 3 - filter("T1"."C2"=10) 4 - access("T1"."C1"="T2"."C1") filter("T1"."C1"="T2"."C1")

10 © 2005 Julian Dyke juliandyke.com 10 DBMS_XPLAN  Partition pruning information can also be included e.g. for a range partitioned table EXPLAIN PLAN FOR SELECT c2 FROM t1 WHERE c1 >= 150 AND c1 < 250; CREATE TABLE t1 (c1 NUMBER,c2 NUMBER,c3 CHAR(50)) PARTITION BY RANGE (c1) ( PARTITION p1 VALUES LESS THAN (100), PARTITION p2 VALUES LESS THAN (200), PARTITION p3 VALUES LESS THAN (300), PARTITION p4 VALUES LESS THAN (400) ); SELECT * FROM TABLE (dbms_xplan.display);

11 © 2005 Julian Dyke juliandyke.com 11 DBMS_XPLAN  Example output for partition pruning IdOperationNameRowsBytesCostPStartPStop 0SELECT STATEMENT1262 1PARTITION RANGE ITERATOR23 * 2TABLE ACCESS FULLT Predicate Information (identified by operation id): 2 - filter("T1"."C1">=150 AND "T1"."C1"<250)


Download ppt "© 2005 Julian Dyke juliandyke.com 1 V$SQL_PLAN  Introduced in Oracle 9.0.1  Shows actual execution plan in memory  Enhanced in Oracle 9.2 to include."

Similar presentations


Ads by Google