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

**URL:** <https://www.ruby-forum.com/t/re-re-does-ror-oracle-use-bind-variables/58217>\
**Category:** Rails\
**Created:** [April 19, 2006, 6:14pm UTC](https://www.ruby-forum.com/t/re-re-does-ror-oracle-use-bind-variables/58217 "2006-04-19T18:14:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![BergerS\_Daniel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bc8723/32.png) [@BergerS\_Daniel](https://www.ruby-forum.com/u/BergerS_Daniel)\
**Post date:** [April 19, 2006, 6:14pm UTC](https://www.ruby-forum.com/t/re-re-does-ror-oracle-use-bind-variables/58217/1 "2006-04-19T18:14:32Z")

</div>

> like we’ll always have that tradeoff. 🙂  
> 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

---

<div class="post-metadata">

**Author:** ![BergerS\_Daniel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bc8723/32.png) [@BergerS\_Daniel](https://www.ruby-forum.com/u/BergerS_Daniel)\
**Post date:** [April 19, 2006, 6:26pm UTC](https://www.ruby-forum.com/t/re-re-does-ror-oracle-use-bind-variables/58217/2 "2006-04-19T18:26:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![BergerS\_Daniel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bc8723/32.png) [@BergerS\_Daniel](https://www.ruby-forum.com/u/BergerS_Daniel)\
**Post date:** [April 19, 2006, 7:04pm UTC](https://www.ruby-forum.com/t/re-re-does-ror-oracle-use-bind-variables/58217/3 "2006-04-19T19:04:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![BergerS\_Daniel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bc8723/32.png) [@BergerS\_Daniel](https://www.ruby-forum.com/u/BergerS_Daniel)\
**Post date:** [April 19, 2006, 7:26pm UTC](https://www.ruby-forum.com/t/re-re-does-ror-oracle-use-bind-variables/58217/4 "2006-04-19T19:26:21Z")

</div>

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.
