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 -> Index Not Used with Parameterized Query

Index Not Used with Parameterized Query

From: Biff Gaut <biff_gaut_at_hotmail.com>
Date: 23 Dec 2003 17:18:06 -0800
Message-ID: <a6090148.0312231718.40367f16@posting.google.com>


The following query returns its results from our database in well under a second-

SELECT
  DISTINCT I.COL1,
  I.COL2,
  E.COL3,
   E.COL1
 FROM
  TABLE1 I,
  TABLE2 E
 WHERE
  I.COL1 = E.COL1 AND
  I.COL2 LIKE 'AVALUE%' If we convert the query to use a bind variable-

SELECT
  DISTINCT I.COL1,
  I.COL2,
  E.COL3,
   E.COL1
 FROM
  TABLE1 I,
  TABLE2 E
 WHERE
  I.COL1 = E.COL1 AND
  I.COL2 LIKE :LastName

and specify the parameter as 'AVALUE%' we get the same resultset, but the query takes 25-50 seconds. Running a trace on the server reveals that the index on E.COL1 is being used in the first case and is not used in the second case. Can anyone explain to me why the index isn't used in the latter example and what changes I can make to ensure that it is used?

Thanks,
Biff Gaut
Gaithersburg, MD Received on Tue Dec 23 2003 - 19:18:06 CST

Original text of this message

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