RE: Re: Does RoR + Oracle use bind variables?


#1

like we’ll always have that tradeoff. :slight_smile:
Yep. You could also stick some cache or parallel hints in there as well
that way.

Can you do me a favor and trap one of these queries in your dev log?
I want to make sure that what I told you is true. I’ve been doing
some research (meet my assistant, Mr. Google), and I’m finding some
discussions from the end of 2004 that imply that the functionality
you want could be in place in the Oracle adapter. I’ll try to track
it down from my end as well.

The OCI8 driver definitely supports bind parameters, so I’m guessing the
adapter would use them as well, though I’m not positive.

I actually don’t know how useful bind parameters are going to be in the
context of web development, since users are (presumably) going to be
bouncing around to different pages doing different queries, and thus the
previous queries would be bumped out of the cache. I guess it depends
on your schema and SGA setup.

Regards,

Dan


#2

I think Oracle is a clever beast, If it recognises that the same query
is being used then it wont have to compile it again. It can only
recognise that the same query is being used if you use bind variables.

Chris


#3

Hello,

I did a quick test and can confirm that neither of the forms
presented in the Conditions section of the ActiveRecord::Base uses
Oracle bind parameters. So, each statement is parsed by the Oracle
parser.

What a shame!

-Anthony


#4

This is because SQL generation is handled by ActiveRecord itself, not
by the specific connection adapters. I’m not a giant fan of that
decision, but I do understand why it was made.
Still, you don’t need to bother with these optimizations until you’ve
profiled your app. If it isn’t fast enough for you, you can easily
use an Oracle-specific query to fetch the data you need.