Title: RE: FW: bind vars change explain plan

Guys,

The developer is right.  The fact is that the optimizer not knowing what the value will be might not use PK or other indexes when you think it should - have seen this before.  The solution in our case since the index had more than one column was to order by more than one column in the index.  Yes, we did not use hints because (1) didn't want to create view and force hint to be used always - would not be appropriate in all cases and downright performance degr, (2) couldn't change the selection criteria (where predicate) would be inaccurate, (3) For whatever reason could not use hints (can't remember why) however, just adding one of the other columns in the composite index to the order actually allowed us to use the index. 

-----Original Message-----
From: Nicoll, Iain (Calanais) [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 22, 2002 12:29 PM
To: Multiple recipients of list ORACLE-L
Subject: RE: FW: bind vars change explain plan


I thought it was simply that with values the optimizer could look at the
histograms to see if data was skewed, whereas it couldn't with bind
variables.  So the index may not have too many distinct values but the
values you were supplying had less than their fair share of records.  I'd
guess that someone at some point has done a analyze table for all indexes
(or something similar) on the particular table. 

I'd also tend to agree though that it's better to hint the index rather than
use values (if that is in your control)

-----Original Message-----
Sent: Monday, July 22, 2002 4:39 PM
To: Multiple recipients of list ORACLE-L


Barbara,

    The path that the optimizer chooses is based on what values are bound
into
the variables, but also on what information it has in the data dictionary.
If
those particular tables/indexes have not been analyzed recently then the
optimizer will make wrong decisions.  Also init parameters like
db_file_multiblock_read_count can prejudice the optimizer to a particular
path
over others.  I would not so much blame the use of bind variables before
looking
at the data dictionary entries for the table/indexes and the init.ora file.
And
yes, the optimizer in 7.x was flaky, at best.

Dick Goulet

____________________Reply Separator____________________
Author: "Baker; Barbara" <[EMAIL PROTECTED]>
Date:       7/22/2002 7:08 AM

prem.
Never did get an answer to this question.  I don't know why using bind
variables changed the execution path.  My best guess comes from the
developer.  She thinks that when we supplied the values, the optimizer knew
what the range of values would be, and could therefore determine to use the
index.  With the bind variable, the optimizer did not have a range of values
to work with and therefore did not choose the index in the execution path.

I have no knowledge that using bind variables will suppress indexes.  Just
happened that it did in this case.
Also keep in mind that this particular database is using an old version of
Oracle (7.3.4).  Optimizer got much better in version 8.

The list helped me out with a work-around, which was to index-hint the index
I wanted.

Bind variables are definitely "good guys".  I highly recommend you continue
with your code changes to include binds.

Good luck.
Barb


> ----------
> From:         oraora  oraora[SMTP:[EMAIL PROTECTED]]
> Reply To:     oraora  oraora
> Sent:         Sunday, July 21, 2002 8:24 PM
> To:   [EMAIL PROTECTED]
> Subject:      Re: bind vars change explain plan
>
> Baker,
>
> sorry i did not read the reply to ur query.
> what was the reply ?
> will using bind vars suppress index ?
> kindly let me know b'coz i have also changed my code to SQL with
> bind vars just now.
>
> Regards,
> prem.
>
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Baker, Barbara
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author:
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Nicoll, Iain (Calanais)
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Reply via email to