Skip to Main Content

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, OnkarNath.

Asked: November 05, 2012 - 11:57 pm UTC

Last updated: November 06, 2012 - 8:59 am UTC

Version: 11.1.0

Viewed 1000+ times

You Asked

Tom,

How the cost in execution plan is calculated?

I ran below query:
explain plan for select * from emp where ename like 'S%';

and the execution plan is:

select * from table (dbms_xplan.display());

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------
Plan hash value: 3956160932

--------------------------------------------------------------------------
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |      |     2 |    74 |     3   (0)| 00:00:01 |
|*  1 |  TABLE ACCESS FULL| EMP  |     2 |    74 |     3   (0)| 00:00:01 |
--------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   1 - filter("ENAME" LIKE 'S%')

13 rows selected.


-Onkar


and Tom said...

it is a function of the number of IO's we expect to have to perform and the amount of CPU we believe we'll need to use.

There are way too many variables to go into any more detail than that.

If you are really interested in some of the internals (I would strongly encourage you to master the fundementals first - read the server concepts guide, learn all about sql), you can check out:

http://www.amazon.com/Cost-Based-Oracle-Fundamentals-Experts-Voice/dp/1590596366/ref=sr_1_2?s=books&ie=UTF8&qid=1352213912&sr=1-2&keywords=lewis+oracle

http://www.amazon.com/Oracle-Core-Essential-Internals-Developers/dp/1430239549/ref=sr_1_1?s=books&ie=UTF8&qid=1352213912&sr=1-1&keywords=lewis+oracle

Is this answer out of date? If it is, please let us know via a Comment

More to Explore

DBMS_XPLAN

More on PL/SQL routine DBMS_XPLAN here