1Jonathan Lewis EOUG Jun 2000 Execution Plans Explain Plan - part 2 Parallel - Partitions - Problems
2Jonathan Lewis EOUG Jun 2000 Execution Plans Parallel - Partitions - Problems Execution Plans - reprise Interpreting Parallel Queries Interpreting Partition table queries New mysteries
3Jonathan Lewis EOUG Jun 2000 Execution Plans Execution Plans - reprise select ep1.v1, count(ep2.v2) fromep2, ep1 whereep2.v1 = 'Tyne Tees' andep1.n1 = ep2.n1 group by ep1.v1 order by count(ep2.v2) desc ;
4Jonathan Lewis EOUG Jun 2000 Execution Plans Execution Plans - reprise SELECT STATEMENT (choose) SORT (order by) SORT (group by) HASH JOIN TABLE ACCESS (analyzed) EP1 (full) TABLE ACCESS (analyzed) EP2 (full)
5Jonathan Lewis EOUG Jun 2000 Execution Plans Parallel Execution
6Jonathan Lewis EOUG Jun 2000 Execution Plans Parallel Execution SORT (order by) PARA_2_SERIAL:Q SORT (group by) PARA_2_PARA:Q HASH JOIN PARA_2_PARA:Q TABLE ACCESS EP2(full) P_2_P :Q TABLE ACCESS EP1(full) P_2_P :Q819001
7Jonathan Lewis EOUG Jun 2000 Execution Plans Parallel Execution
8Jonathan Lewis EOUG Jun 2000 Execution Plans Parallel Execution :Q819000SELECT /*+ NO_EXPAND ROWID(A1) */ A1."N1" C0,A1."V2" C1 FROM "EP2" A1 WHERE ROWID BETWEEN :B1 AND :B2 AND A1."V1"='Tyne Tees' :Q819001SELECT /*+ NO_EXPAND ROWID(A1) */ A1."N1" C0,A1."V1" C1 FROM "EP1" A1 WHERE ROWID BETWEEN :B1 AND :B2
9Jonathan Lewis EOUG Jun 2000 Execution Plans Parallel Execution :Q819004SELECT A1.C0 C0,A1.C1 C1 FROM:Q A1 ORDER BY A1.C0 DESC :Q819003SELECT COUNT(A1.C1) C0,A1.C0 C1 FROM:Q A1 GROUP BY A1.C0 :Q819002SELECT /*+ ORDERED NO_EXPAND USE_HASH(A2) */ A2.C1 C0,A1.C1 C1 FROM:Q A1, :Q A2 WHERE A2.C0=A1.C0
10Jonathan Lewis EOUG Jun 2000 Execution Plans Parallel Execution select tq_id, server_type, process, num_rows, bytes, waits from v$pq_tqstat order by tq_id, server_type desc;
11Jonathan Lewis EOUG Jun 2000 Execution Plans Parallel Execution ID SERVER_TYP PROCESS ROWS BYTES WAITS 0 Producer P P P Consumer P P P Producer P P P Consumer P P P
12Jonathan Lewis EOUG Jun 2000 Execution Plans Parallel Execution
13Jonathan Lewis EOUG Jun 2000 Execution Plans Parallel Execution SORT (order by) PARA_2_SERIAL:Q SORT (group by) PARA_2_PARA:Q NESTED LOOPS PARA_2_PARA :Q TABLE ACCESS EP2(full) P_WITH_Parent TABLE ACCESS EP1(by index rowid) P_W_P INDEX UNIQUE EP1_PK (unique) P_W_P
14Jonathan Lewis EOUG Jun 2000 Execution Plans Parallel Execution SELECT /*+ ORDERED NO_EXPAND USE_NL(A2) INDEX(A2 "EP1_PK") */ A2."V1" C0, A1.C1 C1 FROM (SELECT /*+ NO_EXPAND ROWID(A3) */ A3."N1" C0,A3."V2" C1 FROM "EP2" A3 WHERE ROWID BETWEEN :B1 AND :B2 AND A3."V1"='Tyne Tees' )A1, "EP1"A2 WHERE A2."N1" = A1.C0
15Jonathan Lewis EOUG Jun 2000 Execution Plans PQ Summary Node, Other, Other_tag V$PQ_TQSTAT Messages can be the main cost
16Jonathan Lewis EOUG Jun 2000 Execution Plans Parallel - Partitions - Problems Partitioned tables
17Jonathan Lewis EOUG Jun 2000 Execution Plans Partitioned Tables create table ep1 (n1, v1, v2) partition by range (n1) ( partition p1 values less than (50), partition p2 values less than (100), partition p3 values less than (150) ) as select...
18Jonathan Lewis EOUG Jun 2000 Execution Plans Partitioned Tables select max(v1) from ep1 where n1 = 45 SORT (AGGREGATE) TABLE ACCESS (BY LOCAL INDEX ROWID) OF EP1 INDEX (UNIQUE SCAN) OF 'EP1_PK' (UNIQUE)
19Jonathan Lewis EOUG Jun 2000 Execution Plans Partitioned Tables select max(v1) from ep1 where n1 between 45 and 60; SORT (AGGREGATE) PARTITION RANGE (ITERATOR) TABLE ACCESS (FULL) OF 'EP1'
20Jonathan Lewis EOUG Jun 2000 Execution Plans Partitioned Tables create table ref_n1 (r1 number, c1 varchar2(10)); selectc1, max(n1) fromref_n1,ep1 whereref_n1.c1 like 'S%' and ep1.n1 = ref_n1.r1 group by ref_n1.c1;
21Jonathan Lewis EOUG Jun 2000 Execution Plans Partitioned Tables SORT (GROUP BY) NESTED LOOPS TABLE ACCESS (FULL) OF 'REF_N1' PARTITION RANGE (ITERATOR) INDEX (UNIQUE SCAN) OF 'EP1_PK' (UNIQUE)
22Jonathan Lewis EOUG Jun 2000 Execution Plans Partitioned Tables SORT (AGGREGATE) TABLE ACCESS (BY LOCAL INDEX ROWID) OF EP1 INDEX (UNIQUE SCAN) OF 'EP1_PK' (UNIQUE) SORT (aggregate) TABLE ACCESS (ana) JPL1 EP1 (by local index rowid) Pt id: 2 Pt Range: INDEX (ana) UNIQUE JPL1 EP1_PK (range scan) Pt id: 2 Pt Range: 1 - 1
23Jonathan Lewis EOUG Jun 2000 Execution Plans Partitioned Tables SORT (AGGREGATE) PARTITION RANGE (ITERATOR) TABLE ACCESS (FULL) OF 'EP1' SORT (AGGREGATE) PARTITION RANGE (ITERATOR) Pt id: 2 Pt Range: TABLE ACCESS (FULL) OF 'EP1' Pt id: 2 Pt Range: 1 - 2
24Jonathan Lewis EOUG Jun 2000 Execution Plans Partitioned Tables SORT (group by) NESTED LOOPS TABLE ACCESS REF_N1 (full) PARTITION RANGE (iterator) Pt id: 4 Pt Range: KEY - KEY INDEX (analyzed) UNIQUE EP1_PK (unique scan) Pt id: 4 Pt Range: KEY - KEY
25Jonathan Lewis EOUG Jun 2000 Execution Plans Partitioned Tables select max(v1) from ep1 where n1 = to_number(:b1)
26Jonathan Lewis EOUG Jun 2000 Execution Plans Partitioned Tables SORT (aggregate) PARTITION RANGE (single) Pt id: 2 Pt Range: KEY - KEY TABLE ACCESS (ana) JPL1 EP1 (by local index rowid) Pt id: 2 Pt Range: KEY - KEY INDEX (analyzed) UNIQUE JPL1 EP1_PK (range scan) Pt id: 2 Pt Range: KEY - KEY
27Jonathan Lewis EOUG Jun 2000 Execution Plans Partitioned Tables select ep1.v1, count(ep2.v2) fromep2, ep1 whereep2.v1 = 'Tyne Tees' andep2.n1 between 80 and 120 andep1.n1 = ep2.n1 group by ep1.v1
28Jonathan Lewis EOUG Jun 2000 Execution Plans Partitioned Table SORT (GROUP BY) PARTITION RANGE (ITERATOR) HASH JOIN TABLE ACCESS (FULL) OF 'EP1' TABLE ACCESS (FULL) OF 'EP2' SORT (GROUP BY) HASH JOIN PARTITION RANGE (ITERATOR) TABLE ACCESS (FULL) OF 'EP1' PARTITION RANGE (ITERATOR) TABLE ACCESS (FULL) OF 'EP2'
29Jonathan Lewis EOUG Jun 2000 Execution Plans Partitioned Tables create table ep1 (n1, v1, v2) partition by range (n1) ( partition p1 values less than (50), partition p2 values less than (100), partition p3 values less than (150), partition p4 values less than (250) ) as select...
30Jonathan Lewis EOUG Jun 2000 Execution Plans Partitioned Tables create table ep2 (n1, n2, v1, v2) partition by range (n1) ( partition p1 values less than (51), partition p2 values less than (101), partition p3 values less than (151), partition p4 values less than (251) ) as select...
31Jonathan Lewis EOUG Jun 2000 Execution Plans Partitioned Tables SORT (group by) PARTITION RANGE(iterator) Ptid: 2 Pt Rng: 2-3 HASH JOIN TABLE ACCESS EP1(full)Ptid: 2 Pt Rng: 2-3 TABLE ACCESS EP2(full)Ptid: 2 Pt Rng: 2-3 SORT(group by) HASH JOIN PARTITION RANGE(iterator)Ptid: 3 Pt Rng: 2-3 TABLE ACCESS EP1(full)Ptid: 3 Pt Rng: 2-3 PARTITION RANGE(iterator)Ptid: 5 Pt Rng: 2-3 TABLE ACCESS EP2(full)Ptid: 5 Pt Rng: 2-3
32Jonathan Lewis EOUG Jun 2000 Execution Plans Partitioned Tables SELECT /*+ ORDERED NO_EXPAND USE_HASH(A2) SWAP_JOIN_INPUTS(A2) */ A2.C1 C0,A1.C1C1 FROM (SELECT /*+ NO_EXPAND FULL(A3) */ A3."N1" C0,A3."V2" C1 FROM "EP2" PARTITION(:B1) A3 WHERE A3."V1"='Tyne Tees' AND A3."N1">=80 AND A3."N1"<=120) A1, (SELECT /*+ NO_EXPAND FULL(A4) */ A4."N1" C0,A4."V1" C1 FROM "EP1" PARTITION(:B1)A4 WHERE A4."N1">=80 AND A4."N1"<=120) A2 WHERE A2.C0=A1.C0
33Jonathan Lewis EOUG Jun 2000 Execution Plans Partitioned Tables SELECT /*+ ORDERED NO_EXPAND USE_HASH(A2) SWAP_JOIN_INPUTS(A2)*/ A2.C1 C0,A1.C1 C1 FROM (SELECT /*+ NO_EXPAND FULL(A3) */ A3."N1" C0,A3."V2" C1 FROM "EP2" PARTITION_SET(1) A3 WHERE A3."V1"='Tyne Tees' AND A3."N1">=80 AND A3."N1"<=120) A1, :Q A2 WHERE A2.C0=A1.C0 SELECT /*+ NO_EXPAND ROWID(A1) */ A1."N1" C0,A1."V1" C1 FROM "EP1" PARTITION(:B1) A1 WHERE ROWID BETWEEN :B2 AND :B3 AND A1."N1">=80 AND A1."N1"<=120
34Jonathan Lewis EOUG Jun 2000 Execution Plans Partition Summary Partition ID Partition Start / Partition Stop KEY - KEY vs strictly numbered Iterator / Single
35Jonathan Lewis EOUG Jun 2000 Execution Plans Parallel - Partitions - Problems Problems
36Jonathan Lewis EOUG Jun 2000 Execution Plans Problems select sum(sales_value) from rls_demo; SORT (AGGREGATE) TABLE ACCESS (FULL) OF 'RLS_DEMO'
37Jonathan Lewis EOUG Jun 2000 Execution Plans Problems SORT (AGGREGATE) NESTED LOOPS VIEW SORT (UNIQUE) TABLE ACCESS (FULL) OF 'RLS_CONTROL' TABLE ACCESS (FULL) OF 'RLS_DEMO'
38Jonathan Lewis EOUG Jun 2000 Execution Plans Problems 'owner in ( selectt.owner fromrls_control t wheremanager = sys_context(''rls_demo'',''role'') )'
39Jonathan Lewis EOUG Jun 2000 Execution Plans Problems create type jpl_item as object (n1 number, v1 varchar2(32)); / create type jpl_tab_type as table of jpl_item; / create table demo_nest ( idnumber, nestjpl_tab_type ) nested table nest store as t_nested;
40Jonathan Lewis EOUG Jun 2000 Execution Plans Problems select sum(n.n1) from demo_nestt, table(t.nest)n where n.v1 = 'asdf';
41Jonathan Lewis EOUG Jun 2000 Execution Plans Problems SORT (AGGREGATE) TABLE ACCESS (BY INDEX ROWID) OF 'T_NESTED' INDEX (RANGE SCAN) OF 'TN_V1' (NON-UNIQUE) Where has the parent table DEMO_NEST gone ?
42Jonathan Lewis EOUG Jun 2000 Execution Plans Problems selectit1.location, it1.sales, ( selectsum(sales) from inline_test ita where ita.area = it1.area andita.location_type = it1.location_type ) area_sales frominline_testit1 whereit1.location_type != 'WAREHOUSE';
43Jonathan Lewis EOUG Jun 2000 Execution Plans Problems SELECT STATEMENT Optimizer=CHOOSE TABLE ACCESS (FULL) OF 'INLINE_TEST' Where is the in-line table ?
44Jonathan Lewis EOUG Jun 2000 Execution Plans Problem Summary alter session set events ‘10046 trace name context forever, level 12’
45Jonathan Lewis EOUG Jun 2000 Execution Plans Conclusion ? ?