Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Different explain plans for a query on SQL Plus and PL/SQL

Re: Different explain plans for a query on SQL Plus and PL/SQL

From: Brian Peasland <dba_at_nospam.peasland.net>
Date: Fri, 3 Nov 2006 16:27:52 GMT
Message-ID: <J85xqJ.7sE@igsrsparc2.er.usgs.gov>


barraboombarrabin wrote:
> Hi,
> I have a couple of queries where there explain plan that I get from
> TOAD or SQL Plus is different from the explain plan that is being used
> when the same select statement is executed from PL/SQL package (which I
> determined by looking at V$SQL_PLAN table). The table is truncated and
> loaded with data every day and during the data load process the indexes
> are dropped and recreated after the data load. After the index creation
> is done, the table in question is also analyzed using dbms_stats.
> I would like to use a hint only as a last resort.
> I would appreciate it if someone can help me with some steps that can
> be taken to ensure that the explain plan within the PL/SQL is the
> desired one without using the hint.
>
> Note that the index SCP_STORE_ITEM_MD_NU_IDX01 has the same columns
> that are in the where clause of the select statement.
>
> Plan from TOAD
>
> Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop
>
> SELECT STATEMENT Optimizer Mode=CHOOSE 897 755
>
> TABLE ACCESS BY LOCAL INDEX
> ROWID EBIPROD.SCP_ODS_STORE_ITEM_MODELS 897 38 K 755
> 3 3
> INDEX RANGE SCAN EBIPROD.SCP_STORE_ITEM_MD_NU_IDX01 897 4
> 3 3
>
> Plan from V$SQL_PLAN
> -----------------------------------------------------------------------------------------------------
> | Id | Operation | Name | Rows |
> Bytes | Cost | Pstart| Pstop |
> -----------------------------------------------------------------------------------------------------
> | 0 | SELECT STATEMENT | | |
> | 59 | | |
> | 1 | PARTITION RANGE SINGLE| | |
> | | KEY | KEY |
> | 2 | TABLE ACCESS FULL | SCP_ODS_STORE_ITEM_MODELS | 491 |
> 25532 | 59 | KEY | KEY |
> -----------------------------------------------------------------------------------------------------
>
> Any help would be appreciated
>
> Thanks
>

Which version of Oracle?

Cheers,
Brian

-- 
===================================================================

Brian Peasland
dba_at_nospam.peasland.net
http://www.peasland.net

Remove the "nospam." from the email address to email me.


"I can give it to you cheap, quick, and good.
Now pick two out of the three" - Unknown
Received on Fri Nov 03 2006 - 10:27:52 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US