1 Chapter 13 Parallel SQL. 2 Understanding Parallel SQL Enables a SQL statement to be: – Split into multiple threads – Each thread processed simultaneously.

Slides:



Advertisements
Similar presentations
Maria Colgan & Thierry Cruanes
Advertisements

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,
Introduction to SQL Tuning Brown Bag Three essential concepts.
Module 13: Performance Tuning. Overview Performance tuning methodologies Instance level Database level Application level Overview of tools and techniques.
© Bharati Vidyapeeths Institute of Computer Applications and Management, New Delhi © Bharati Vidyapeeths Institute of Computer Applications and.
What Happens when a SQL statement is issued?
1 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
© 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.
Copyright © 200\8 Quest Software High Performance PL/SQL Guy Harrison Chief Architect, Database Solutions.
Oracle Architecture. Instances and Databases (1/2)
Agenda Overview of the optimizer How SQL is executed Identifying statements that need tuning Explain Plan Modifying the plan.
1 - Oracle Server Architecture Overview
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 11 Database Performance Tuning and Query Optimization.
Chapter 9 Overview  Reasons to monitor SQL Server  Performance Monitoring and Tuning  Tools for Monitoring SQL Server  Common Monitoring and Tuning.
Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server.
Executing Explain Plans and Explaining Execution Plans Craig Martin 01/20/2011.
Troubleshooting SQL Server Enterprise Geodatabase Performance Issues
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Database Performance Tuning and Query Optimization.
Chapter Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.
Oracle Database Administration Lecture 6 Indexes, Optimizer, Hints.
By Lecturer / Aisha Dawood 1.  You can control the number of dispatcher processes in the instance. Unlike the number of shared servers, the number of.
Physical Database Design & Performance. Optimizing for Query Performance For DBs with high retrieval traffic as compared to maintenance traffic, optimizing.
Module 7 Reading SQL Server® 2008 R2 Execution Plans.
The Model Clause explained Tony Hasler, UKOUG Birmingham 2012 Tony Hasler, Anvil Computer Services Ltd.
1 Chapter 7 Optimizing the Optimizer. 2 The Oracle Optimizer is… About query optimization Is a sophisticated set of algorithms Choosing the fastest approach.
1 Oracle Architectural Components. 1-2 Objectives Listing the structures involved in connecting a user to an Oracle server Listing the stages in processing.
Copyright  Oracle Corporation, All rights reserved. 1 Oracle Architectural Components.
Oracle Tuning Ashok Kapur Hawkeye Technology, Inc.
Query Processing. Steps in Query Processing Validate and translate the query –Good syntax. –All referenced relations exist. –Translate the SQL to relational.
1 Chapter 14 DML Tuning. 2 DML Performance Fundamentals DML Performance is affected by: – Efficiency of WHERE clause – Amount of index maintenance – Referential.
Star Transformations Tony Hasler, UKOUG Birmingham 2012 Tony Hasler, Anvil Computer Services Ltd.
Parallel Execution Plans Joe Chang
Large Data Operations Joe Chang
Parallel Execution Plans Joe Chang
1 Chapter 10 Joins and Subqueries. 2 Joins & Subqueries Joins – Methods to combine data from multiple tables – Optimizer information can be limited based.
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.
1 Chapter 17 Shared Memory Contention. 2 Overview Specifically talking about SGA – Buffer Cache – Redo Log Buffer Contention in these areas of SGA – Can.
Module 4 Database SQL Tuning Section 3 Application Performance.
Query Optimizer Execution Plan Cost Model Joe Chang
D Copyright © Oracle Corporation, All rights reserved. Loading Data into a Database.
Oracle Database Performance Secrets Finally Revealed Greg Rahn & Michael Hallas Oracle Real-World Performance Group Server Technologies.
Chapter 4 Logical & Physical Database Design
Chapter 1Oracle9i DBA II: Backup/Recovery and Network Administration 1 Chapter 1 Backup and Recovery Overview MSCD642 Backup and Recovery.
Chapter 5 Index and Clustering
Session 1 Module 1: Introduction to Data Integrity
Lecture 14- Parallel Databases Advanced Databases Masood Niazi Torshiz Islamic Azad University- Mashhad Branch
1 Chapter 9 Tuning Table Access. 2 Overview Improve performance of access to single table Explain access methods – Full Table Scan – Index – Partition-level.
1 Chapter 8 Execution Plan Management. 2 Overview of Execution Plan Management Review techniques to – override optimizer – Improve optimizer’s decisions.
Oracle9i Developer: PL/SQL Programming Chapter 11 Performance Tuning.
Best Practices in Loading Large Datasets Asanka Padmakumara (BSc,MCTS) SQL Server Sri Lanka User Group Meeting Oct 2013.
8 Copyright © 2005, Oracle. All rights reserved. Gathering Statistics.
Database Systems, 8 th Edition SQL Performance Tuning Evaluated from client perspective –Most current relational DBMSs perform automatic query optimization.
1 11g NEW FEATURES ByVIJAY. 2 AGENDA  RESULT CACHE  INVISIBLE INDEXES  READ ONLY TABLES  DDL WAIT OPTION  ADDING COLUMN TO A TABLE WITH DEFAULT VALUE.
Diving into Query Execution Plans ED POLLACK AUTOTASK CORPORATION DATABASE OPTIMIZATION ENGINEER.
11 Copyright © 2009, Oracle. All rights reserved. Enhancing ETL Performance.
Tuning Oracle SQL The Basics of Efficient SQL Common Sense Indexing
Introduction to Partitioning in SQL Server
SQL Server Statistics and its relationship with Query Optimizer
DB Tuning Ch 14. Parallel Processing Ch 15. Performance of DML Ch 16. Analytic Function Jaeseok Myung Intelligent Database Systems Lab School of Computer.
SQL Trace and TKPROF.
Scaling SQL with different approaches
Database Performance Tuning and Query Optimization
Parallelism Concepts.
Chapter 11 Database Performance Tuning and Query Optimization
Diving into Query Execution Plans
Performance Tuning ETL Process
Presentation transcript:

1 Chapter 13 Parallel SQL

2 Understanding Parallel SQL Enables a SQL statement to be: – Split into multiple threads – Each thread processed simultaneously Used with multi-CPU systems Serial method only uses one CPU Only available in Oracle Enterprise Edition

3 Serial processing Only single CPU used for a query SELECT * FROM customers ORDER BY cust_first_name, cust_last_name, cust_year_of_birth; Single process proceses all rows in above query – Rows fetched – Rows sorted – Rows returned

4 Parallel processing Multiple CPU’s can be used for a query SELECT /+* parallel(c,2) */ * FROM customers c ORDER BY cust_first_name, cust_last_name, cust_year_of_birth; Multiple processes for all rows in above query – Fetching process split into two – At end of fetch, two sort processes are invoked – Then, sorted results combined and returned – The “query coordinator” coordinates the parallelism processing stream

5 Parallel processing Restricted to operations needing a scan – Table – Index – Table partition Can become bottleneck is misused Shouldn’t be used for non-tuned SQL

6 Degree of Parallelism Also known as “DOP” Defines number of streams that will be created Number of actual processes 2x or greater than DOP – Data fed between steps – Two steps required to maintain parallel stream Example statement with below requires 5 processes for DOP of 2 (see. Figure 13-2 p. 398) – Full table scan – ORDER_BY – GROUP_BY

7 Parallel Slave Pool Configured with Oracle parameters – PARALLEL_MIN_SERVERS – PARALLEL_MAX_SERVERS Slaves created as needed for parallel SQL Slaves shut down after period of inactivity If more slaves required than maximum allowed – Query DOP may be reduced – Query may run serially – Query may generate error – Query may be delayed until slaves available

8 Direct Path IO Normal IO path for parallel operations Bypasses buffer cache (avoids contention) Perform IO directly Used when reading/writing temporary segments – For sorting – For intermediate result sets

9 When to use Parallelism Server has multiple CPU’s Data is spread across multiple disk drives SQL is long-running or resource-intensive – Long running reports – Large table bulk updates – Index builds/rebuilds on large tables – Analytic or other ad-hoc intensive processing If above criteria not met, using parallelism may be slower than running serial process Not suitable for OLTP systems

10 Configuring Parallelism Key parameters include – PARALLEL_THREADS_PER_CPU – PARALLEL_DEGREE_POLICY – PARALLEL_ADAPTIVE_MULTI_USER – PARALLEL_IO_CAP – PARALLEL_MAX SERVERS – PARALLEL_MIN_SERVERS – See pp for full list Default DOP is 2x CPU if not configured

11 Parallel Hints Invoked within SQL statements Examples: SELECT /*+ parallel */ * FROM sales s SELECT /*+ parallel(s) */ * FROM sales s SELECT /*+ parallel(s,8) */ * FROM sales s SELECT /*+ noparallel */ COUNT(*) FROM sales s SELECT /*+ parallel(auto) */ COUNT(*) FROM sales s

12 Parallel Explain Plans More complex than serial SQL plans SQL> select /*+ parallel(a,8) */ count(*) 2 from emp a | Id | Operation | Name | Cost (%CPU)| | 0 | SELECT STATEMENT | | 266 (1)| | 1 | SORT AGGREGATE | | | | 2 | PX COORDINATOR | | | | 3 | PX SEND QC (RANDOM) | :TQ10000 | | | 4 | SORT AGGREGATE | | | | 5 | PX BLOCK ITERATOR | | 266 (1)| PLAN_TABLE_OUTPUT | 6 | TABLE ACCESS FULL| EMP | 266 (1)|

13 Parallel Explain Plans (cont.) PX Block Iterator – First Step – Breaks table up into chunks PX Send – Indicates data being sent from one process to another PX Receive – Indicates data being received by one process from another PX SEND QC – Send operation to the query coordindator PX COORDINATOR – Indicates query coordinator receiving data from parallel streams and returning it to the SQL statement

14 Parallel Explain Plans (cont.) PARALLEL_FROM_SERIAL (or S->P) – Represents a serial bottleneck in a parallel operation – See table 13-1 (p. 411) for full list Parallel data distribution options – RANGE – Rows distributed based on value range – HASH – Based on hash value – RANDOM – Rows randomly assigned to slave – ROUND ROBIN – Done in circular fashion between slaves

15 Tracing Parallel Execution Use DBMS_SESSION to set session identifier Use DBMS_MONITOR to enable tracing Run the parallel SQL Use trcsess utility to create trace file Analyze results Should be used as last resort

16 Other Parallel Statistics V$PQ_TQSTAT view – Contains information about Actual DOP used Data transferred between parallel processes – Limited use: Only visible within session that executed the parallel SQL Only shows most recent statement V$PX_SESSION – Information about slaves currently running SQL – Join to V$SESSION and V$SQL to get all details

17 Optimizing Parallel Performance Start with SQL optimized for serial execution Ensure the SQL is suitable for parallelism Ensure server is configured for parallelism Ensure all parts of the execution plan is parallelized Ensure the DOP is realistic Monitor actual DOP Check for workload and data skew

18 Other Parallel Topics Parallel Index Lookups – Usually not parallelizable – Can be parallelized on partitioned indexes – Done with PARALLEL_INDEX hint Parallel DML – Enable with ‘alter session enable parallel dml;’ – Parallel Insert particularly effective Parallelize both SELECT and INSERT operations Uses APPEND method (bypasses buffer cache) – Parallel Merge (Merge combines UPDATE & INSERT)

19 Other Parallel Topics (cont.) DBMS_PARALLEL_EXECUTE – Introduced in 11g – Can execute operations in smaller chunks – Committed individually – Restartable – Done with PARALLEL_INDEX hint Parallel DDL – Controlled by parallel clause in the DDL statement – DOP then set at specified degree for subsequent queries