|
|
|
|
Re: Difference between cost and %CPU? [message #389537 is a reply to message #389350] |
Mon, 02 March 2009 09:43 |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
Assuming that your server isn't CPU bound (ie isn't running at or near full load on it's cpu), you want to pick the best query on neither of these figures.
As Ross said - the best query is the one that returns the results the fastest, so measure how long they take, and pick the quickest.
|
|
|
|
Re: Difference between cost and %CPU? [message #389694 is a reply to message #389670] |
Tue, 03 March 2009 04:14 |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
Quote: | On what basis shall i pick the quickest one
|
Eh?
What?
We seem to be having a total failure of communication here.
Imagine if I gave you two sticks of different lengths, and, when told to pick the longest one you said 'On what basis shall I pick the longest one?'
Your reply above makes the same amount of sense.
You pick the quickest query on the basis of it taking the least time to execute - what other conceivable answer could there be?
|
|
|
|
|
Re: Difference between cost and %CPU? [message #389743 is a reply to message #389741] |
Tue, 03 March 2009 07:44 |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
One other point - in your initial post, you are comparing figures from the explain plans of two different queries - albeit ones that return the same results.
This is pointless - the only thing you can compare the Cost of a query's execution plan to is another execution plan for the same query.
|
|
|
|
Re: Difference between cost and %CPU? [message #389773 is a reply to message #389744] |
Tue, 03 March 2009 09:21 |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
Quote: | the execution plans of the same query would always be the same right?
|
Not at all - Hints can change execution plans.
Addition or removal of indexes and constraints can change execution plans.
Changes in the statistics for a table can change an execution plan.
Stored Outlines can change an execution plan.
Several init.ora parameters can change execution plans.
The Cost shown on the Explain plan is a figure that the CBO calculates for each execution path that it looks at when it parses a query. It will pick the execution path with the lowest cost.
Costs are broadly comparable across similar queries - things with very high costs will almost always take longer than things with very low costs, but it's no more accurate than that.
|
|
|
|