1Jonathan Lewis EOUG Jun 2000 Execution Plans Explain Plan - part 2 Parallel - Partitions - Problems.

Slides:



Advertisements
Similar presentations
Youre Smarter than a Database Overcoming the optimizers bad cardinality estimates.
Advertisements

8 Copyright © 2005, Oracle. All rights reserved. Parallel Operations in Data Warehouses.
1.
Tuning Oracle SQL The Basics of Efficient SQLThe Basics of Efficient SQL Common Sense Indexing The Optimizer –Making SQL Efficient Finding Problem Queries.
Tuning: overview Rewrite SQL (Leccotech)Leccotech Create Index Redefine Main memory structures (SGA in Oracle) Change the Block Size Materialized Views,
Presented By Akin S Walter-Johnson Ms Principal PeerLabs, Inc
Understanding SQL Server Query Execution Plans
Introduction to SQL Tuning Brown Bag Three essential concepts.
M ODULE 4 D ATABASE T UNING Section 3 Application Performance 1 ITEC 450 Fall 2012.
© Bharati Vidyapeeths Institute of Computer Applications and Management, New Delhi © Bharati Vidyapeeths Institute of Computer Applications and.
Jonathan Lewis EOUG Jun 2000 Execution Plans Agenda What are execution plans Where do you find execution plans Key mechanisms of execution Understanding.
What Happens when a SQL statement is issued?
CS 245Notes 71 CS 245: Database System Principles Notes 7: Query Optimization Hector Garcia-Molina.
EXECUTION PLANS By Nimesh Shah, Amit Bhawnani. Outline  What is execution plan  How are execution plans created  How to get an execution plan  Graphical.
Query Execution, Concluded Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems November 18, 2003 Some slide content may.
Dos and don’ts of Columnstore indexes The basis of xVelocity in-memory technology What’s it all about The compression methods (RLE / Dictionary encoding)
Semantec Ltd. Oracle Performance Tuning Boyan Pavlov Indexes Indexes.
Agenda Overview of the optimizer How SQL is executed Identifying statements that need tuning Explain Plan Modifying the plan.
David Konopnicki Choosing Access Path ä The basic methods. ä The access paths and when they are available. ä How the optimizer chooses among the.
Virtual techdays INDIA │ 9-11 February 2011 SQL 2008 Query Tuning Praveen Srivatsa │ Principal SME – StudyDesk91 │ Director, AsthraSoft Consulting │ Microsoft.
Optimization Exercises. Question 1 How do you think the following query should be computed? What indexes would you suggest to use? SELECT E.ename, D.mgr.
AN INTRODUCTION TO EXECUTION PLAN OF QUERIES These slides have been adapted from a presentation originally made by ORACLE. The full set of original slides.
The query processor does what the query plan tells it to do A “good” query plan is essential for a well- performing.
Sarah Sproehnle Cloudera, Inc
SQL Tuning Ohio Oracle User’s Group October 2002 © Copyright, Kris T. Mason, 2002.
Executing Explain Plans and Explaining Execution Plans Craig Martin 01/20/2011.
A few things about the Optimizer Thomas Kyte
Lecture 8 Index Organized Tables Clusters Index compression
Oracle Database Administration Lecture 6 Indexes, Optimizer, Hints.
Physical Database Design & Performance. Optimizing for Query Performance For DBs with high retrieval traffic as compared to maintenance traffic, optimizing.
Denny Cherry Manager of Information Systems MVP, MCSA, MCDBA, MCTS, MCITP.
Module 7 Reading SQL Server® 2008 R2 Execution Plans.
Csci 5708 : Execution Plan -Bhavtosh Rath. Syntax: SELECT * FROM TABLE (DBMS_XPLAN. DISPLAY(‘PLAN_TABLE',‘ ')); DISPLAY function: Displays result/content.
Ashwani Roy Understanding Graphical Execution Plans Level 200.
The Model Clause explained Tony Hasler, UKOUG Birmingham 2012 Tony Hasler, Anvil Computer Services Ltd.
11-1 Improve response time of interactive programs. Improve batch throughput. To ensure scalability of applications load vs. performance. Reduce system.
Parallel Database Systems Instructor: Dr. Yingshu Li Student: Chunyu Ai.
Star Transformations Tony Hasler, UKOUG Birmingham 2012 Tony Hasler, Anvil Computer Services Ltd.
Parallel Execution Plans Joe Chang
SQL Performance and Optimization l SQL Overview l Performance Tuning Process l SQL-Tuning –EXPLAIN PLANs –Tuning Tools –Optimizing Table Scans –Optimizing.
Oracle tuning: a tutorial Saikat Chakraborty. Introduction In this session we will try to learn how to write optimized SQL statements in Oracle 8i We.
Module 4 Database SQL Tuning Section 3 Application Performance.
SQL Tuning 101 excerpt: Explain Plan A Logical Approach Michael Ruckdaschel Affinion Group International.
Oracle Database Performance Secrets Finally Revealed Greg Rahn & Michael Hallas Oracle Real-World Performance Group Server Technologies.
1 Chapter 13 Parallel SQL. 2 Understanding Parallel SQL Enables a SQL statement to be: – Split into multiple threads – Each thread processed simultaneously.
J.NemecAre Your Statistics Bad Enough?1 Verify the effectiveness of gathering optimizer statistics Jaromir D.B. Nemec UKOUG
Chapter 5 Index and Clustering
Query Optimization CMPE 226 Database Systems By, Arjun Gangisetty
Last Updated : 27 th April 2004 Center of Excellence Data Warehousing Group Teradata Performance Optimization.
2010 Ami Levin. SQL Server implements three different physical operators to perform joins. In this session we will see how each of these three operators.
David Konopnicki –1997, Rev. MS Optimizing Join Statements To choose an execution plan for a join statement, the optimizer must choose: ä Access.
DB Tuning : Chapter 10. Optimizer Center for E-Business Technology Seoul National University Seoul, Korea 이상근 Intelligent Database Systems Lab School of.
Sorting and Joining.
Query Processing and Query Optimization CS 157B Dennis Le Weishan Wang.
LAB: Web-scale Data Management on a Cloud Lab 11. Query Execution Plan 2011/05/27.
Diving into Query Execution Plans ED POLLACK AUTOTASK CORPORATION DATABASE OPTIMIZATION ENGINEER.
SAP Tuning 실무 SK㈜ ERP TFT.
Tuning Oracle SQL The Basics of Efficient SQL Common Sense Indexing
Scaling SQL with different approaches
Choosing Access Path The basic methods.
Interpreting Execution Plans
Physical Join Operators
Execution Plans Demystified
Chapter 4 Summary Query.
Performance Join Operator Select * from R, S where R.a = S.a;
Turning Plans into Trees
EXECUTION PLANS Quick Dive.
Welcome!.
All about Indexes Gail Shaw.
Presentation transcript:

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 ? ?