Hi,
What is the difference between find_by_sql and ruby find method?
Where I use find_by_sql ? and Where I use find query?
Is there any performance related difference between them? If yes then,
which is feasible to use?
Thanks & Regards,
Tushar
Hi,
What is the difference between find_by_sql and ruby find method?
Where I use find_by_sql ? and Where I use find query?
Is there any performance related difference between them? If yes then,
which is feasible to use?
Thanks & Regards,
Tushar
It’s not the Ruby find, it’s the Rails find method. find_by_sql will
let you write your own SQL query for especially complex queries or
perhaps you don’t like the way Rails is doing it. the find method just
puts in all the stuff like "SELECT * FROM table
"… I suggest getting
yourself a good ruby book and a good rails book and learning about
each and the differences.
Hi Tushar
The call which one to use and when is completely developer’s call.
Of course find_by_sql is faster than Rails finder method but it is
subjected to scalability.
check-out this link for more:
P.S. It’s better to use Rails finder methods so that your application
will remain database independent.
On Aug 13, 1:21 am, Tushar G. [email protected]
On 13 Aug 2008, at 10:55, Gourav T. wrote:
Hi Tushar
The call which one to use and when is completely developer’s call.
Of course find_by_sql is faster than Rails finder method but it is
subjected to scalability.
find just calls find_by_sql so there’s not going to be a big speed
difference due to the use of find itself (for equivalent sql,
obviously if you can write a faster query than the one find generates
then find_by_sql will be faster)
Fred
Unless that find is in a loop that is called million times per request
i believe performance is not an issue. However find_by_sql makes code
uglier so unless you really need it don’t use it.
On Aug 13, 1:08 pm, Frederick C. [email protected]
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs