Jatin Kumar wrote in post #972576:
> On Wed, Jan 5, 2011 at 5:50 PM, Marnen Laibow-Koser
> <[email protected]>wrote:
>
>> >
>> certain operations.
>>
>> Could you name some of these certain operations where its better to go for
> SQL queries instead of ActiveRecord.

I didn't mean to use raw SQL *instead of* ActiveRecord.  But sometimes 
ActiveRecord's abstractions aren't terribly good (notably with bulk and 
aggregate operations, as well as certain types of joins), and 
find_by_sql becomes necessary.

> Also, is ARel also inefficient for the certain operations that you are
> mentioning??

I haven't used Arel yet, so I'm not sure.

> Until now, I have learned that you should not write SQl queries in your
> code, rather go for Active Record, as it allows you to change your
> choice of
> database later on.

That is true.

> But, If you are certain that you are going to use
> MySQL
> or a specific DB for an app then I guess there is no problem in going
> for
> SQL queries.

Not quite.  If I need literal SQL (which is rare), my practice is to 
write it as far as possible in terms compliant with standard ANSI SQL 
syntax, without proprietary extensions.  This gives the best portability 
across databases.

> Please correct me, if I am wrong somewhere.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

-- 
Posted via http://www.ruby-forum.com/.

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to