Would it be possiblein the future to see Active Record generate Prepare and Bind SQL statements rather than passing literals to the DB? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Fri, Jun 27, 2008 at 7:17 AM, Jorg Lueke <jlueke_2000-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> Would it be possiblein the future to see Active Record generate > Prepare and Bind SQL statements rather than passing literals to the DB?Yes. Why? jeremy --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Jun 27, 11:26 am, "Jeremy Kemper" <jer...-w7CzD/W5Ocjk1uMJSBkQmQ@public.gmane.org> wrote:> On Fri, Jun 27, 2008 at 7:17 AM, Jorg Lueke <jlueke_2...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote: > > Would it be possiblein the future to see Active Record generate > > Prepare and Bind SQL statements rather than passing literals to the DB? > > Yes. Why? > > jeremyBecause, at least in DB2, you have much lower cost preparing select c1 from t1 where c1 = ? rather than c1 = ''Hi'' DB2 caches the queries that come in and all that use the ? are equivalent thus there is no new overhead in determining the access method. With literals, unless they are identical each literal will cause more overhead. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Just to satisfy my own curiosity...does this need to be included in ActiveRecord. Couldn''t this be implemented in the DB2 adapter? Thanks guys. Mike On Jun 27, 2008, at 2:36 PM, Jorg Lueke wrote:> > > > On Jun 27, 11:26 am, "Jeremy Kemper" <jer...-w7CzD/W5Ocjk1uMJSBkQmQ@public.gmane.org> wrote: >> On Fri, Jun 27, 2008 at 7:17 AM, Jorg Lueke <jlueke_2...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> >> wrote: >>> Would it be possiblein the future to see Active Record generate >>> Prepare and Bind SQL statements rather than passing literals to >>> the DB? >> >> Yes. Why? >> >> jeremy > > Because, at least in DB2, you have much lower cost preparing select c1 > from t1 where c1 = ? rather than c1 = ''Hi'' > DB2 caches the queries that come in and all that use the ? are > equivalent thus there is no new overhead in determining the access > method. With literals, unless they are identical each literal will > cause more overhead. > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Well I did ask about the ibm_db adapter first but since the SQL is generated in active record the adapter wouldn''t know what was a parameter originally. Also, I checked and Oracle and SQL Server work the same way. Since the cost of preparing a literal is 10x preparing out of cache in all three major databases it seems like a worthwhile addition. On Jun 27, 3:32 pm, Michael Breen <hard...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Just to satisfy my own curiosity...does this need to be included in > ActiveRecord. Couldn''t this be implemented in the DB2 adapter? > > Thanks guys. > Mike > > On Jun 27, 2008, at 2:36 PM, Jorg Lueke wrote: > > > > > On Jun 27, 11:26 am, "Jeremy Kemper" <jer...-w7CzD/W5Ocjk1uMJSBkQmQ@public.gmane.org> wrote: > >> On Fri, Jun 27, 2008 at 7:17 AM, Jorg Lueke <jlueke_2...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> > >> wrote: > >>> Would it be possiblein the future to see Active Record generate > >>> Prepare and Bind SQL statements rather than passing literals to > >>> the DB? > > >> Yes. Why? > > >> jeremy > > > Because, at least in DB2, you have much lower cost preparing select c1 > > from t1 where c1 = ? rather than c1 = ''Hi'' > > DB2 caches the queries that come in and all that use the ? are > > equivalent thus there is no new overhead in determining the access > > method. With literals, unless they are identical each literal will > > cause more overhead.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks for the reply Jorg. On Jun 27, 2008, at 6:09 PM, Jorg Lueke wrote:> > Well I did ask about the ibm_db adapter first but since the SQL is > generated in active record the adapter wouldn''t know what was a > parameter originally. Also, I checked and Oracle and SQL Server work > the same way. Since the cost of preparing a literal is 10x preparing > out of cache in all three major databases it seems like a worthwhile > addition. > > > On Jun 27, 3:32 pm, Michael Breen <hard...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> Just to satisfy my own curiosity...does this need to be included in >> ActiveRecord. Couldn''t this be implemented in the DB2 adapter? >> >> Thanks guys. >> Mike >> >> On Jun 27, 2008, at 2:36 PM, Jorg Lueke wrote: >> >> >> >>> On Jun 27, 11:26 am, "Jeremy Kemper" <jer...-w7CzD/W5Ocjk1uMJSBkQmQ@public.gmane.org> wrote: >>>> On Fri, Jun 27, 2008 at 7:17 AM, Jorg Lueke <jlueke_2...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> >>>> wrote: >>>>> Would it be possiblein the future to see Active Record generate >>>>> Prepare and Bind SQL statements rather than passing literals to >>>>> the DB? >> >>>> Yes. Why? >> >>>> jeremy >> >>> Because, at least in DB2, you have much lower cost preparing >>> select c1 >>> from t1 where c1 = ? rather than c1 = ''Hi'' >>> DB2 caches the queries that come in and all that use the ? are >>> equivalent thus there is no new overhead in determining the access >>> method. With literals, unless they are identical each literal will >>> cause more overhead. > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---