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: Slow query when using parameters

Re: Slow query when using parameters

From: John Gasch <jgasch_at_erols.com>
Date: 2000/03/31
Message-ID: <38E57B5D.DCBCCAD@erols.com>#1/1

I have seen this happen in cases where the bind variable was declared as a different type than the query predicate expects, forcing the query parser to do an implicit data conversion. For instance:

SELECT * FROM Table WHERE numericField = 123; -- runs fast, assuming Table.numericField is indexed

But an implicit TO_CHAR conversion is performed on numericField in the following procedure, so the numericField index will not be used:

CREATE PROCEDURE aProc ( p_arg VARCHAR2) IS BEGIN
   SELECT * FROM Table WHERE numericField = p_arg; END; In that case, use TO_NUMBER(p_arg) in the SELECT statement (and add an exception handler in case p_arg is not a numeric string).

Hope this helps.

John Gasch


pmartin_at_mitsa.ch wrote:
>
> Hello
>
> I've got a performance problem with a query.
> The query is in a procedure in a package (although this seems to make
> no difference).
>
> The parameters for the query are passed as arguments to the procedure.
>
> With the parameters passed as arguments the query takes 1 minute 40
> seconds to run. However if I 'hardcode' the paramter values the query
> only takes 11 seconds to run.
>
> I've tried putting the parameters passed to the stored procedure
> into local variables and then use the local variables in the query but
> this doesn't change anything.
>
> Can anybody explain this difference ?
>
> Many thanks
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
  Received on Fri Mar 31 2000 - 00:00:00 CST

Original text of this message

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