Thanks Jonathan, I actually have more properties and relationships which were removed for the sake of the example. You are right though, the performance gain was not as I hoped it would be.
I'll have to think of other methods (caching maybe)... On Sep 4, 2014 11:50 PM, "Jonathan Vanasco" <[email protected]> wrote: > > > On Thursday, September 4, 2014 2:19:34 PM UTC-4, Ofir Herzas wrote: >> >> Nevertheless, is there a way to achieve what I want? (which is to >> selectively load several columns and this 'jobs' property from Employee) >> > > The ways I usually do that are: > > 1. Select the other object. Query for EmployeeJob, and then "load only" > the Employee columns. > > 2. Explicitly load columns. I'm not sure if this will work for > relationships: > > session.query( TableClass.column_a, TableClass.column_b).all() > > instead of returning an ORM object, you get a tuple. > > 3. Define a column as deferred in the mapper [ > http://docs.sqlalchemy.org/en/latest/orm/mapper_config.html#deferred-column-loading > ] > > Looking at your example though, unless you have very high traffic -- > you're not going to have a significant performance gain with a query like > that. Your tables don't have many columns, and they're not very large. > People are usually concerned about load_only when you have very large > fields (BLOBS, TEXT, HSTORE) or complex joins and need to save memory. > > You might just be better off letting the ORM load stuff you don't need -- > you'll get much more code done that way. > > -- > You received this message because you are subscribed to a topic in the > Google Groups "sqlalchemy" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/sqlalchemy/OprfrGJcoJU/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
