On Aug 25, 2009, at 11:19 AM, Mike Orr wrote: > One major advantage of SQLAlchemy is the SQL level, which is several > times faster than the ORM for making bulk changes. This feature is > mentioned in passing but perhaps it should be emphasized more in > Pylons marketing. SQLAlchemy is not "just an ORM" like the others. > > I have found the ORM useful in the following cases: > > - Retrieve an object and modify it with the least amount of fuss. > - Add-or-modify an object that may or may not exist. > - Looping through lots of objects when you don't care if the process > takes a long time. > > The SQL level is more useful for: > > - Looping through 1+ million records in a read-only manner. > - Inserting many records that you know do not exist yet. > - Bulk changes that can be done in a single statement. (Set all X > field to 0, or add 5 to the current value.) > - Modifying the table structure in place.
The performance slowdowns of the ORM mean I always inevitable end up going to the lower SA SQL level. It's worth noting that doing so is substantially more pleasant in SA 0.5 since you can pretty much use the entire ORM style query language but going for specific attributes. I usually end up with the ORM stuff used a lot up front initially in the app, then later as I do more complex queries and need performance, drop down to using the faster SQL level layer. The ORM setup is invaluable though, as it provides a great domain model organization for all the lower level queries (which are all class/instance methods), and it makes writing the SA SQL layer stuff a lot easier since all the relationships are configured. Cheers, Ben --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pylons-discuss" 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/pylons-discuss?hl=en -~----------~----~----~----~------~----~------~--~---
