Welcome Guest, Not a member yet? Register   Sign In
Joins: Controller or Model?
#9

[eluser]danmontgomery[/eluser]
[quote author="n0xie" date="1267743710"][quote author="Denarius" date="1267680487"]Is there any performance gain in writing traditional queries against using the ActiveRecord constructs? [/quote]
Yes, writing your own SQL will almost always be faster, since the AR has to 'guess' what you intend to do when it builds your query. AR is a handy tool for writing 'simple' queries. I would write more complex queries by hand: it's faster and you know exactly what's going on.[/quote]

This is technically true, AR has to construct your query, but once it's constructed the actual query is run exactly the same way... For the overwhelming majority of applications this difference will be negligible. I do agree with n0xie, though, that for complex queries it's faster (for me) to write them by hand, mainly to avoid AR incorrectly escaping queries, or because of functionality that's missing (subqueries, grouping where clauses, etc).


Messages In This Thread
Joins: Controller or Model? - by El Forum - 03-02-2010, 08:50 AM
Joins: Controller or Model? - by El Forum - 03-02-2010, 08:54 AM
Joins: Controller or Model? - by El Forum - 03-02-2010, 10:08 AM
Joins: Controller or Model? - by El Forum - 03-02-2010, 03:12 PM
Joins: Controller or Model? - by El Forum - 03-03-2010, 12:45 PM
Joins: Controller or Model? - by El Forum - 03-03-2010, 01:03 PM
Joins: Controller or Model? - by El Forum - 03-03-2010, 05:28 PM
Joins: Controller or Model? - by El Forum - 03-04-2010, 11:01 AM
Joins: Controller or Model? - by El Forum - 03-04-2010, 11:13 AM
Joins: Controller or Model? - by El Forum - 03-04-2010, 05:21 PM



Theme © iAndrew 2016 - Forum software by © MyBB