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: explain plan changes if using bind vars

Re: explain plan changes if using bind vars

From: William Robertson <william.robertson_at_bigfoot.com>
Date: 2 Aug 2005 11:09:23 -0700
Message-ID: <1123006163.161692.240320@g14g2000cwa.googlegroups.com>


NetComrade wrote:
> On 2 Aug 2005 10:18:30 -0700, "AK" <AK_TIREDOFSPAM_at_hotmail.COM> wrote:
>
> >I used /*+ CURSOR_SHARING_EXACT */ in a similar situation
> >
>
> Great.. didn't know this existed.
> This will work for now, and won't look as ugly as wrapping with two
> alter session statements.
>
> Thanks.
> .......
> We use Oracle 8.1.7.4 and 9.2.0.5 on Solaris 2.7 boxes
> remove NSPAM to email

Am I missing something? Setting CURSOR_SHARING = EXACT restores the default setting:
http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96536/ch131.htm#REFRN10025

as does the CURSOR_SHARING_EXACT hint:
http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96533/hintsref.htm#6650

As I understand it, if you have set CURSOR_SHARING = something other than the default EXACT, but you want the CBO to treat a query as if you hadn't (that is, you want to prevent it from replacing all your literals with bind variables), then hinting with CURSOR_SHARING_EXACT should do the trick.

You would typically set CURSOR_SHARING = SIMILAR or FORCE if you had code that didn't use bind variables but you wish it did.

The situation described above seems to be the reverse of that, in that bind variables can give the optimizer less information to go on than literals, and in some circumstances that can adversely affect the execution plan. There is no CURSOR_SHARING_SIMILAR or CURSOR_SHARING_FORCE hint AFAIK.

Still if it works for you, then great. Received on Tue Aug 02 2005 - 13:09:23 CDT

Original text of this message

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