Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Total cost of a query through Oracle's explain plan

I am a bit new to Oracle and I am have a question regarding Oracle's explain plan. I have used the 'auto-trace' feature for a particular query.

SQL> SELECT * from myTable; 11 rows selected. Elapsed: 00:00:00.01

Execution Plan
----------------------------------------------------------
Plan hash value: 1233351234

----------------------------------------------------------------------------
| Id  | Operation         | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
----------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |        |    11 |   330 |     3   (0)| 00:00:01 |
|   1 |  TABLE ACCESS FULL| MYTABLE|    11 |   330 |     3   (0)| 00:00:01 |
----------------------------------------------------------------------------

My question is if I want to calculate the 'total' cost of this query, is it 6 (3+3) or its only 3. Suppose I had a larger query with more steps in the plan, do I have to add up all the values in the cost column to get the total cost or is it the first value (ID=0) that is the total cost of a query?

like image 766
Maya Avatar asked May 01 '11 20:05

Maya


2 Answers

Cost is 3, the plan is shown as a hierarchy, with the cost of the sub-components already included in the parent components.

like image 176
BeeOnRope Avatar answered Oct 19 '22 04:10

BeeOnRope


You might also want to take a look at some of the responses to: How do you interpret a query's explain plan?

like image 31
Andrew Avatar answered Oct 19 '22 06:10

Andrew