LAB: Web-scale Data Management on a Cloud Lab 11. Query Execution Plan 2011/05/27.

Slides:



Advertisements
Similar presentations
Tuning Oracle SQL The Basics of Efficient SQLThe Basics of Efficient SQL Common Sense Indexing The Optimizer –Making SQL Efficient Finding Problem Queries.
Advertisements

Presented By Akin S Walter-Johnson Ms Principal PeerLabs, Inc
A Guide to SQL, Seventh Edition. Objectives Use joins to retrieve data from more than one table Use the IN and EXISTS operators to query multiple tables.
Jonathan Lewis EOUG Jun 2000 Execution Plans Agenda What are execution plans Where do you find execution plans Key mechanisms of execution Understanding.
1Jonathan Lewis EOUG Jun 2000 Execution Plans Explain Plan - part 2 Parallel - Partitions - Problems.
What Happens when a SQL statement is issued?
Copyright © 2004 Pearson Education, Inc.. Chapter 15 Algorithms for Query Processing and Optimization.
Drop in replacement of MySQL. Agenda MySQL branch GPL licence Maria storage engine Virtual columns FederatedX storage engine PBXT storage engine XtraDB.
INTRODUCTION TO ORACLE Lynnwood Brown System Managers LLC Performance And Tuning – Lecture 7 Copyright System Managers LLC 2007 all rights reserved.
Presented by, MySQL AB® & O’Reilly Media, Inc. Applied Partitioning and Scaling Your (OLTP) Database System Phil Hildebrand thePlatform.
Midterm Review Lecture 14b. 14 Lectures So Far 1.Introduction 2.The Relational Model 3.Disks and Files 4.Relational Algebra 5.File Org, Indexes 6.Relational.
Agenda Overview of the optimizer How SQL is executed Identifying statements that need tuning Explain Plan Modifying the plan.
SQL 2 – The Sequel R&G, Chapter 5 Lecture 10. Administrivia Homework 2 assignment now available –Due a week from Sunday Midterm exam will be evening of.
Introduction to Structured Query Language (SQL)
David Konopnicki Choosing Access Path ä The basic methods. ä The access paths and when they are available. ä How the optimizer chooses among the.
Introduction to Structured Query Language (SQL)
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.
Kirkwood Center for Continuing Education By Fred McClurg, Introduction to PHP and MySQL Copyright © 2010 All Rights Reserved.
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.
Relational Database Performance CSCI 6442 Copyright 2013, David C. Roberts, all rights reserved.
Executing Explain Plans and Explaining Execution Plans Craig Martin 01/20/2011.
Database System Architecture and Performance CSCI 6442 ©Copyright 2015, David C. Roberts, all rights reserved.
Lecture 8 Index Organized Tables Clusters Index compression
Oracle Database Administration Lecture 6 Indexes, Optimizer, Hints.
Dbwebsites 2.1 Making Database backed Websites Session 2 The SQL… Where do we put the data?
MySQL. Dept. of Computing Science, University of Aberdeen2 In this lecture you will learn The main subsystems in MySQL architecture The different storage.
Denny Cherry Manager of Information Systems MVP, MCSA, MCDBA, MCTS, MCITP.
Ashwani Roy Understanding Graphical Execution Plans Level 200.
SQL pepper. Why SQL File I/O is a great deal of code Optimal file organization and indexing is critical and a great deal of code and theory implementation.
Query Processing. Steps in Query Processing Validate and translate the query –Good syntax. –All referenced relations exist. –Translate the SQL to relational.
11-1 Improve response time of interactive programs. Improve batch throughput. To ensure scalability of applications load vs. performance. Reduce system.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Mark Inman U.S. Navy (Naval Sea Logistics Center) Session #213 Analytic SQL for Beginners.
SQL Performance and Optimization l SQL Overview l Performance Tuning Process l SQL-Tuning –EXPLAIN PLANs –Tuning Tools –Optimizing Table Scans –Optimizing.
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.
Module 4 Database SQL Tuning Section 3 Application Performance.
Proactively Optimizing Queries with EXPLAIN and mk-query-digest Presented by: Sheeri K. Cabral Database Operations Manager MySQL Sunday at Oracle OpenWorld.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
SQL Tuning 101 excerpt: Explain Plan A Logical Approach Michael Ruckdaschel Affinion Group International.
Indexes and Views Unit 7.
PowerBuilder Online Courses - by Prasad Bodepudi Database Painter Primary & Foreign Keys Extended Attributes PowerBuilder System Tables Database Profiles.
Last Updated : 27 th April 2004 Center of Excellence Data Warehousing Group Teradata Performance Optimization.
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.
Kirkwood Center for Continuing Education By Fred McClurg, Introduction to PHP and MySQL Copyright © 2015, Fred McClurg, All Rights.
Sorting and Joining.
Query Processing – Implementing Set Operations and Joins Chap. 19.
Optimization and Administartion of a Database Management Systems Krystian Zieja.
Query Processing and Query Optimization CS 157B Dennis Le Weishan Wang.
Oracle9i Developer: PL/SQL Programming Chapter 11 Performance Tuning.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
Eugene Meidinger Execution Plans
MySQL Tutorial. Databases A database is a container that groups together a series of tables within a single structure Each database can contain 1 or more.
Execution Plans Detail From Zero to Hero İsmail Adar.
Bend SQL to Your Will With EXPLAIN Ligaya Turmelle MySQL Support Engineer
1 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database How MySQL.com Improved their Database Performance with Query Analyzer.
Tuning Oracle SQL The Basics of Efficient SQL Common Sense Indexing
Optimizing MySQL Joins and Subqueries
Choosing Access Path The basic methods.
Using SQL Server through Command Prompt
MySQL Explain examples
Database Management  .
ISC440: Web Programming 2 Server-side Scripting PHP 3
Chapter 4 Indexes.
CH 4 Indexes.
CH 4 Indexes.
Execution plans Eugene
Databases Continued 10/18/05.
Presentation transcript:

LAB: Web-scale Data Management on a Cloud Lab 11. Query Execution Plan 2011/05/27

Announcement HOMEWORK #4 –Due: 6/9 Thur. (2 weeks left) FINAL EXAM –6/14 Tues. 17:00 PROJECT #1 –Due: 6/17 Fri.

movieLens Database 1,000,209 3,883 6,040 idgenderageoccup ation zipcode 1F M M …………… idtitlegenres 1Toy StoryAnimation|Child ren’s|Comedy 21Waiting to Exhale Comedy|Drama 104Get ShortyAction|Comedy| Drama ………. useridmovieidratingts (timestamp) …………

Table Access Full mysql> EXPLAIN SELECT * FROM users; | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | | 1 | SIMPLE | users | ALL | NULL | NULL | NULL | NULL | 5891 | | row in set (0.00 sec) mysql> SHOW SESSION STATUS LIKE 'Last_query_cost'; | Variable_name | Value | | Last_query_cost | | row in set (0.02 sec) users

Index Full Scan mysql> EXPLAIN SELECT * FROM users ORDER BY id; | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | | SIMPLE | users | index | NULL | PRIMARY | 4 | NULL | 5891 | | row in set (0.00 sec) (id column is omitted) mysql> SHOW SESSION STATUS LIKE 'Last_query_cost'; | Variable_name | Value | | Last_query_cost | | row in set (0.03 sec) users

Index Unique Scan mysql> EXPLAIN SELECT * FROM users WHERE id = 300; | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | | SIMPLE | users | const | PRIMARY | PRIMARY | 4 | const | 1 | | row in set (0.00 sec) (id column is omitted) mysql> SHOW SESSION STATUS LIKE 'Last_query_cost'; | Variable_name | Value | | Last_query_cost | | row in set (0.03 sec) users

Index Range Scan mysql> EXPLAIN SELECT * FROM users WHERE id BETWEEN 100 AND 1000; | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | | SIMPLE | users | range | PRIMARY | PRIMARY | 4 | NULL | 1728 | Using | | where | row in set (0.00 sec) (id column is omitted) mysql> SHOW SESSION STATUS LIKE 'Last_query_cost'; | Variable_name | Value | | Last_query_cost | | row in set (0.03 sec) users

Index Fast Full Scan mysql> EXPLAIN SELECT id FROM users; | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | | SIMPLE | users | index | NULL | PRIMARY | 4 | NULL | 5891 | Using | | index | row in set (0.00 sec) (id column is omitted) mysql> SHOW SESSION STATUS LIKE 'Last_query_cost'; | Variable_name | Value | | Last_query_cost | | row in set (0.02 sec) users

Join mysql> EXPLAIN SELECT * FROM users, ratings WHERE users.id = ratings.userid; | select_type | table | type | possible_keys | key | key_len | ref | rows | | SIMPLE | users | ALL | PRIMARY | NULL | NULL | NULL | 5915 | | SIMPLE | ratings | ref | PRIMARY | PRIMARY | 4 | users.id | 61 | rows in set (0.00 sec) (id, extra columns are omitted) mysql> SHOW SESSION STATUS LIKE 'Last_query_cost'; | Variable_name | Value | | Last_query_cost | | row in set (0.05 sec) UsersRatings

3-way Join mysql> EXPLAIN SELECT * FROM users, ratings, movies -> WHERE users.id = ratings.userid AND ratings.movieid = movies.id; | select_type | table | type | possible_keys | key | key_len | ref | rows | | SIMPLE | users | ALL | PRIMARY | NULL | NULL | NULL | 5915 | | SIMPLE | ratings | ref | PRIMARY, | PRIMARY | 4 | users.id | 61 | | fk_ratings_movies | | SIMPLE | movies | eq_ref | PRIMARY | PRIMARY | 4 | ratings.movieid | 1 | rows in set (0.00 sec) (id, extra columns are omitted) mysql> SHOW SESSION STATUS LIKE 'Last_query_cost'; | Variable_name | Value | | Last_query_cost | | row in set (0.00 sec) MoviesRatings Users

Oracle with SQL*Plus Oracle Database 10g Express Edition –with SQL*Plus $ sqlplus SQL*Plus: Release Production on Fri May 27 00:04: Copyright (c) 1982, 2005, Oracle. All rights reserved. Enter user-name: student Enter password: csed421 Connected to: Oracle Database 10g Express Edition Release – Production SQL> _

Autotrace in SQL*Plus To get a report on the execution path used by the SQL optimizer and the statement execution statistics – ≒ EXPLAIN in MySQL SQL> set autotrace on –Query result + Execution plan + Statistics SQL> set autotrace traceonly –Execution plan + Statistics ( + Query execution in background) SQL> set autotrace traceonly explain –Execution plan SQL> set autotrace off

Execution Plan CategoriesSubjects Classes

Demos Scan –Table Access Full –Index Full Scan –Index Unique Scan –Index Range Scan –Index Fast Full Scan Join –Hash Join –Nested Loop Join –Sort Merge Join –3-way Join

Table Access Full Users

Index Full Scan Users

Index Unique Scan Users

Index Range Scan Users

Index Fast Full Scan Users

Hash Join Cost: α = 921 UsersRatings

Nested Loop Join Cost: 1000K * α = 1002K UsersRatings

Sort Merge Join Cost: α = 5969 UsersRatings

3-way Join MoviesRatings Users

3-way Outer Join UsersRatings Movies

Internal Sort

External Sort

Analyze Statistics of Table SQL> analyze table table_name compute statistics; SQL> analyze index index_name validate structure;