RE: Bug in Oracle driver ?



If the two statements have different performance characteristics, they
likely have different execution plans.

Have you run "explain plan" on the two statements (with the bind variable
placeholders in place, rather than literals)? Or checked the plans actually
used through v$sql_plan and the bind variable types through
v$sql_bind_metadata? (assuming a recent version of Oracle - what version are
you on?)

You can also run your script with DBI_TRACE=3, this will show binding and
types, for example:

<- prepare= DBI::st=HASH(0x8718eb4) at bind.pl line 8
-> execute for DBD::Oracle::st (DBI::st=HASH(0x8718eb4)~0x8585d40
'1130979589-6919-090637') thr#8585008
bind :p1 <== '1130979589-6919-090637' (type 0)
bind :p1 <== '1130979589-6919-090637' (size 22/23/0, ptype 4, otype
1)

otype 1 is VARCHAR2. Are you getting something different?

Are you running with the cost-based optimiser? Do you have valid optimiser
statistics on the schema?

If you're running the older rule-based optimiser, it has a habit of tending
towards index-based access where this may not actually be the fastest route.
"Tricks" like prefixing strings to columns would make it use full table
scans or filters for parts of the plans instead; for certain shapes of data
and queries this can be faster. But that's not a DBD::Oracle issue, that's
an Oracle tuning issue.

For newer versions of Oracle, then "bind variable peeking" is one thing to
consider when you have differences between running statements with literals
versus using bind variables.

--
Andy Hassall :: andy@xxxxxxxxxxx :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

> -----Original Message-----
> From: Igor Korolev [mailto:ikorolev@xxxxxxxxxxxxxxxx]
> Sent: 21 December 2005 16:35
> To: Tim Bunce
> Cc: dbi-users@xxxxxxxx; c.w.huling@xxxxxxxxx
> Subject: RE: Bug in Oracle driver ?
>
> If the query has where clause
>
> where division_id = :1 and division_order_id = :2
>
> execution tooks way too long taking into account that
> division_id (VARCHAR2) + division_order_id (VARCHAR2) is the
> primary key in this table.
>
>
> A simple addition forcing division_order_id to be VARCHAR,
> dramatically improves performance
>
> where division_id = :1 and division_order_id = '' || :2
>
>
> So, the code obviously binds the second parameter incorrectly.
>
> Thank you,
>
> Igor

.



Relevant Pages

  • RE: Bug in Oracle driver ?
    ... Here are the two queries with the explain plans along with the last time they were analyzed. ... This is a cost-based database. ... Subject: RE: Bug in Oracle driver? ... versus using bind variables. ...
    (perl.dbi.users)
  • Re: PL/SQL Block Query Slow
    ... the two queries are not actually the same query. ... bind variables (pl/sql variables) while the other is using constants. ... It is very likely the CBO is developing different plans for the two ...
    (comp.databases.oracle.misc)
  • Re: high through put system
    ... Not using bind variables is the #1 method to make Oracle unscalable. ... Your post has 'badly engineered app' inscribed all over it. ... Sybrand Bakker, Senior Oracle DBA ... Even when I instruct developers explicitly to start using ...
    (comp.databases.oracle.server)
  • RE: Clob insert problem on a Oracle db with DBI
    ... Use bind variables for your insert statement. ... Clob insert problem on a Oracle db with DBI ... intended recipient, please be aware that any disclosure, copying, distribution ... sender of the delivery error by replying to this message, or notify us by ...
    (perl.dbi.users)
  • RE: performance problem with dbd oracle
    ... performance problem with dbd oracle ... algorithm that Oracle uses to identify sql statement in the library cache. ... Bind variables a very inportant. ...
    (perl.dbi.users)