You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Tom Henricksen <To...@A-t-g.com> on 2007/05/10 23:12:06 UTC

iBatis without Bind variables?

We have a query that is running very slow when running through iBatis
against DB2.  If we pull that query and run through Aqua Data studio
with raw SQL (w/o bind variables) it runs fast.  It seems that DB2 is
picking a different query plan with the bind variables then when we use
raw SQL.  We even went to test iBatis vs JDBC with Bind variables and
JDBC w/o Bind variables.  And iBatis and JDBC with Bind variables were
both slow were JDBC w/o bind variables was fast.  Is it possible to run
iBatis w/o bind variables?  I would doubt it, just wondering if others
have run into similar problems and if you had any suggestions. I
understand bind variables are a good thing.  This just seems like the
exception to the rule where they or the database isn't doing the correct
thing.

 

Thanks,

 

Tom Henricksen
Consultant
Advanced Technologies Group, Inc.


Re: iBatis without Bind variables?

Posted by Koka Kiknadze <22...@gmail.com>.
Well you can go the $$ way as Larry indicated, but he also did warn you ;)

What I liked in iBatis from the very start was that it's ME who controls all
the sql and I can add optimizer hints  in iBatis <select> statements. I use
Oracle, but hope the following applies to DB2 too:  I'd try including hints
in the first place (of course if your problem persists after recomputing
database stats)

GL

On 5/11/07, Tom Henricksen <To...@a-t-g.com> wrote:
>
>  We have a query that is running very slow when running through iBatis
> against DB2.  If we pull that query and run through Aqua Data studio with
> raw SQL (w/o bind variables) it runs fast.  It seems that DB2 is picking a
> different query plan with the bind variables then when we use raw SQL.  We
> even went to test iBatis vs JDBC with Bind variables and JDBC w/o Bind
> variables.  And iBatis and JDBC with Bind variables were both slow were JDBC
> w/o bind variables was fast.  Is it possible to run iBatis w/o bind
> variables?  I would doubt it, just wondering if others have run into similar
> problems and if you had any suggestions. I understand bind variables are a
> good thing.  This just seems like the exception to the rule where they or
> the database isn't doing the correct thing.
>
>
>
> Thanks,
>
>
>
> *Tom Henricksen*
> Consultant
> Advanced Technologies Group, Inc.
>

Re: iBatis without Bind variables?

Posted by Larry Meadors <lm...@apache.org>.
Use $this$ instead of #this# and you'll get subsitution instead of
parameterization - but be careful, you are responsible for all
escaping and type conversion, and opening yourself up to SQL
injection. Unless you are VERY sure that you need to do this...look
for a better solution.

Larry


On 5/10/07, Tom Henricksen <To...@a-t-g.com> wrote:
>
>
>
>
> We have a query that is running very slow when running through iBatis
> against DB2.  If we pull that query and run through Aqua Data studio with
> raw SQL (w/o bind variables) it runs fast.  It seems that DB2 is picking a
> different query plan with the bind variables then when we use raw SQL.  We
> even went to test iBatis vs JDBC with Bind variables and JDBC w/o Bind
> variables.  And iBatis and JDBC with Bind variables were both slow were JDBC
> w/o bind variables was fast.  Is it possible to run iBatis w/o bind
> variables?  I would doubt it, just wondering if others have run into similar
> problems and if you had any suggestions. I understand bind variables are a
> good thing.  This just seems like the exception to the rule where they or
> the database isn't doing the correct thing.
>
>
>
> Thanks,
>
>
>
> Tom Henricksen
>  Consultant
>  Advanced Technologies Group, Inc.