Download presentation
Presentation is loading. Please wait.
Published byBarry Flowers Modified over 9 years ago
1
Csci 5708 : Execution Plan -Bhavtosh Rath
2
Syntax: SELECT * FROM TABLE (DBMS_XPLAN. DISPLAY(‘PLAN_TABLE',‘ ')); DISPLAY function: Displays result/content of the EXECUTION PLAN command stored in the plan table.
3
1. Single table – Point query (Index Scan): SELECT TITLE FROM MOVIE WHERE VOTES = 2; MOVIE title Votes =2 Query tree: SELECT STATEMENT TABLE ACCESS BY INDEX ROWID MOVIE INDEX RANGE SCAN MOVIE_VOTES Execution plan:
4
SELECT TITLE FROM MOVIE WHERE VOTES = 2; PLAN_TABLE output DISPLAY function
5
2. Single table – Range query (Linear Scan): SELECT TITLE FROM MOVIE WHERE VOTES > 2; MOVIE title Votes > 2 Query tree : SELECT STATEMENT Execution plan: TABLE ACCESS FULL MOVIE
6
SELECT TITLE FROM MOVIE WHERE VOTES > 2; PLAN_TABLE output DISPLAY function
7
3. Two table – One JOIN + One point query SELECT a1.NAME FROM ACTOR a1, ACTOR a2 WHERE a1.ID > a2.ID AND a2.NAME = ‘Kent Douglass’; a1.NAME a1.ID > a2.ID Query tree : a2.NAME = ‘Kent Douglass’ ACTOR a2 ACTOR a1 SELECT STATEMENT Execution plan: NESTED LOOPS TABLE ACCESS FULL ACTORTABLE ACCESS BY INDEX ROWID ACTOR INDEX RANGE SCAN
8
SELECT a1.NAME FROM ACTOR a1, ACTOR a2 WHERE a1.ID > a2.ID AND a2.NAME = ‘Kent Douglass’; PLAN_TABLE output DISPLAY function
9
4. Three table – Two joins: SELECT a.NAME, m.TITLE FROM ACTOR a, MOVIE m, CASTING c WHERE a.ID = c.ACTORID AND c.MOVIEID = m.ID; CASTING c a.NAME, m.TITLE a.ID = c.ACTORID Query tree : c.MOVIEID = m.ID MOVIE m ACTOR a SELECT STATEMENT Execution plan: HASH JOIN TABLE ACCESS FULL CASTING TABLE ACCESS FULL ACTOR TABLE ACCESS FULL MOVIE
10
SELECT a.NAME, m.TITLE FROM ACTOR a, MOVIE m, CASTING c WHERE a.ID = c.ACTORID AND c.MOVIEID = m.ID; PLAN_TABLE output DISPLAY function
11
-The End-
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.