Skip to Main Content

Breadcrumb

XMAS_TREE

The AskTOM team is taking a break over the holiday season, so we're not taking questions or responding to comments. Please have a happy and safe festive season and as always, thanks for being a member of the AskTOM community.

Question and Answer

Chris Saxon

Thanks for the question, HR.

Asked: April 10, 2024 - 9:21 pm UTC

Last updated: April 16, 2024 - 10:14 am UTC

Version: 16.2

Viewed 1000+ times

You Asked

Hi,

I used explain plan and got the following results. Based on cost and time, does query 2 perform significantly better than query 1? The runtime for query 1 is approximately 1 minute and 40 seconds, but it shows 07:47:02. Why is the estimated time so different from the actual? Your help is much appreciated!

Query 1:
------------------------------------------------------------------------------
| Id  | Operation         | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
------------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |          | 71730 |  2241K|   717M  (1)| 07:47:02 |
|*  1 |  TABLE ACCESS FULL| TBL1     | 71730 |  2241K|   717M  (1)| 07:47:02 |
------------------------------------------------------------------------------


Query 2:
------------------------------------------------------------------------------
| Id  | Operation         | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
------------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |          | 71730 |  2241K| 51028   (1)| 00:00:02 |
|*  1 |  TABLE ACCESS FULL| TBL1     | 71730 |  2241K| 51028   (1)| 00:00:02 |
------------------------------------------------------------------------------

and Chris said...

Remember that an explain plan is just a prediction - the database's best guess for how long the query will take. This guess can be wrong for many, many reasons.

I'm surprised there's such a big difference in the cost and expected time in these plans. Both full scan the same table and are expected to return the same number of rows.

Please provide more detail - in particular the queries these plans are for and any other information shown in the plan. For example, the Notes & Predicates sections.

We're not taking comments currently, so please try again later if you want to add a comment.