Ashwani Roy Understanding Graphical Execution Plans Level 200.

Slides:



Advertisements
Similar presentations
Tuning: overview Rewrite SQL (Leccotech)Leccotech Create Index Redefine Main memory structures (SGA in Oracle) Change the Block Size Materialized Views,
Advertisements

Understanding SQL Server Query Execution Plans
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)
Slide: 1 Presentation Title Presentation Sub-Title Copyright 2010 Robert Haas, EnterpriseDB Corporation. Creative Commons 3.0 Attribution. The PostgreSQL.
Query Evaluation. An SQL query and its RA equiv. Employees (sin INT, ename VARCHAR(20), rating INT, age REAL) Maintenances (sin INT, planeId INT, day.
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.
Query Optimization 3 Cost Estimation R&G, Chapters 12, 13, 14 Lecture 15.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 11 Database Performance Tuning and Query Optimization.
Introduction to Database Systems 1 Join Algorithms Query Processing: Lecture 1.
Access Path Selection in a Relation Database Management System (summarized in section 2)
Relational Database Performance CSCI 6442 Copyright 2013, David C. Roberts, all rights reserved.
Query Optimization, part 2 CS634 Lecture 13, Mar Slides based on “Database Management Systems” 3 rd ed, Ramakrishnan and Gehrke.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Database Performance Tuning and Query Optimization.
Module 8 Improving Performance through Nonclustered Indexes.
ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez-Martínez Electrical and Computer Engineering Department Lecture 14 – Join Processing.
Module 12: Optimizing Query Performance. Overview Introducing the Query Optimizer Tuning Performance Using SQL Utilities Using an Index to Cover a Query.
Denny Cherry Manager of Information Systems MVP, MCSA, MCDBA, MCTS, MCITP.
Module 7 Reading SQL Server® 2008 R2 Execution Plans.
Database Management 9. course. Execution of queries.
©Silberschatz, Korth and Sudarshan13.1Database System Concepts Chapter 13: Query Processing Overview Measures of Query Cost Selection Operation Sorting.
Data Partitioning in VLDB Tal Olier
Primary Key, Cluster Key & Identity Loop, Hash & Merge Joins Joe Chang
Copyright © Curt Hill Query Evaluation Translating a query into action.
Microsoft AREC TAM Internship SQL Server Performance Tuning(I) Haijun Yang AREC SQL Support Team Feb, SQL Server 2000.
Around the world (of query plan operators) in 50 minutes David Morrison BI Consultant.
Indexes and Views Unit 7.
Query Optimization CMPE 226 Database Systems By, Arjun Gangisetty
Query Processing CS 405G Introduction to Database Systems.
Query Execution. Where are we? File organizations: sorted, hashed, heaps. Indexes: hash index, B+-tree Indexes can be clustered or not. Data can be stored.
David Konopnicki –1997, Rev. MS Optimizing Join Statements To choose an execution plan for a join statement, the optimizer must choose: ä Access.
File Processing : Query Processing 2008, Spring Pusan National University Ki-Joune Li.
Hash Tables and Query Execution March 1st, Hash Tables Secondary storage hash tables are much like main memory ones Recall basics: –There are n.
Query Processing – Implementing Set Operations and Joins Chap. 19.
Relational Operator Evaluation. overview Projection Two steps –Remove unwanted attributes –Eliminate any duplicate tuples The expensive part is removing.
Query Execution Query compiler Execution engine Index/record mgr. Buffer manager Storage manager storage User/ Application Query update Query execution.
Alon Levy 1 Relational Operations v We will consider how to implement: – Selection ( ) Selects a subset of rows from relation. – Projection ( ) Deletes.
Database Systems, 8 th Edition SQL Performance Tuning Evaluated from client perspective –Most current relational DBMSs perform automatic query optimization.
Eugene Meidinger Execution Plans
Scott Fallen Sales Engineer, SQL Sentry Blog: scottfallen.blogspot.com.
Execution Plans Detail From Zero to Hero İsmail Adar.
Diving into Query Execution Plans ED POLLACK AUTOTASK CORPORATION DATABASE OPTIMIZATION ENGINEER.
SQL IMPLEMENTATION & ADMINISTRATION Indexing & Views.
The PostgreSQL Query Planner Robert Haas PostgreSQL East 2010.
Database Management System
Introduction to Execution Plans
Chapter 15 QUERY EXECUTION.
Database Management Systems (CS 564)
The Key to the Database Engine
Physical Join Operators
File Processing : Query Processing
Execution Plans Demystified
SQL Server Query Plans Journeyman and Beyond
Introduction to reading execution plans
Dave Bland LinkedIn SQL Server Execution Plans: How to use them to find performance bottlenecks Dave Bland LinkedIn
Introduction to Execution Plans
Lecture 13: Query Execution
EXECUTION PLANS Quick Dive.
Execution plans Eugene
Evaluation of Relational Operations: Other Techniques
Diving into Query Execution Plans
Introduction to Execution Plans
Reading execution plans successfully
Introduction to Execution Plans
All about Indexes Gail Shaw.
Presentation transcript:

Ashwani Roy Understanding Graphical Execution Plans Level 200

Query Processing lifecycle by Database Engine Elements in a Execution Plans Important Execution Plan Operators Agenda

Query Parsing Query Optimization Query Execution What Happens when a Query is submitted

Query Plan

Logical and Physical Operators Parallelism Physical Operators Cursor Operators Language Elements Operators in an Execution Plan

Columns in a PlanRowsEstimateIO ExecutesEstimateCPU StmtIdAvgRowSize NodeIdTotalSubtreeCost ParentOutputList PhysicalOpWarnings LogicalOpType ArgumentParallel DefinedValuesEstimateExecutions EstimateRows

If a Cached Plan exists then SQL Server will use this cached plan DEMO 01 Cached Query Plans

Important Operators in Execution Plans Select (Result) Sort Clustered Index Seek Clustered Index Scan Non-clustered Index Scan Non-clustered Index Seek Table ScanRID LookupKey LookupHash Match Nested Loops Merge JoinTopCompute Scalar Constant Scan FilterLazy SpoolSpoolEager SpoolStream Aggregate Distribute Streams Repartition Streams Gather Streams BitmapSplit

Index Seek Reads B-tree entries to determine the data page The Argument column contains the name of the nonclustered index being used Prefered for highly selective queries

Index Seek

Index Scan Horizontal traversal of the leaf level of the index from the first page to the last Retrieves all rows from the nonclustered index The Argument column contains the name of the nonclustered index being used

Clustered Index Scan The clustered index scan’s logical and physical operator scans the clustered index The Argument column contains the name of the clustered index If the table does not have Clustered Index the same Query will produce Table Scan

DEMO 02

Clustered Index Seek Cluster index seek Uses the seeking ability of indexes to retrieve rows The Argument column contains the name of the clustered index being used Seek() predicate contains the columns used for seeking

Bookmark Lookups Uses a bookmark to look up a row in a clustered index or table The Argument column contains the bookmark label Can be removed by covering columns May have a performance improvement

KEY LOOKUP A Key Lookup is a bookmark lookup on a table with a clustered index. Means that the optimizer cannot retrieve the rows in a single operation, and has to use a clustered key (or a row ID) to return the corresponding rows from a clustered index (or from the table itself). Performance can be improved by making Non-Clustered Index or Covering Index

DEMO 03

RID Lookup A type of bookmark lookup Occurs on a heap table (a table that doesn't have a clustered index) Uses a row identifier to find the rows to return.

DEMO 04

Nested Loop The top input to the nested loop is the outer table The bottom input to the nested loop is the inner table For each outer row, searches for matching rows are in the inner input table Effective if the outer input is very small and the inner input is preindexed and very large Optimizer sometimes sorts the outer input to improve locality of the searches on the index over the inner input Best when search exploits an index (indexes on join columns are used) Low memory requirement

Hash Join The top input is build input, the smaller of the two inputs The bottom input is probe input The hash join first scans or computes the whole build input Requires at least one equality clause in the join predicate Good for ad-hoc queries

Merge Join Both inputs should be sorted on the merge column keys An index on a correct set of columns is useful A many-to-many merge join uses a temporary table to store rows Very fast if the data that you want can be obtained presorted from existing B-tree indexes

WHICH JOIN IS GOOD NONE AND ALL A Merge Join is an efficient way to join two tables,# when the join columns are pre sorted if the join columns are not pre sorted, the query optimizer has the option of a) sorting the join columns first, then performing a Merge Join, or b) performing a less efficient Hash Join. The query optimizer considers all the options and generally chooses the execution plan that uses the least resources.

DEMO 05

Stream Aggregation The argument column of the plan output shows the list of columns of the GROUP BY or DISTINCT clause The list of aggregate expressions will appear in the Defined Values column of the plan output Best for smaller sets or sets already sorted Input is sorted and output is ordered

Hash Aggregation Used with large sets Aggregations are evaluated while building the hash Input can be in random order; output is always in random order

DEMO 06

Rewinds and Rewinds

Questions THANK YOU