10

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?

Maya
  • 101
  • 1
  • 1
  • 3

2 Answers2

11

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

BeeOnRope
  • 60,350
  • 16
  • 207
  • 386
  • my pleasure I should add that the parent costs are not _just_ the sum of the child costs, since the parent operation has some non-zero cost as well. Often that cost is minimal for many types of non-leaf operations, so it effectively appears as zero, as is the case here. – BeeOnRope May 01 '11 at 21:21
4

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

Community
  • 1
  • 1
Andrew
  • 9,090
  • 8
  • 46
  • 59