On Nov 3, 2011, at 6:03 PM, Kent wrote:

> There are certain properties that lazy=False or 'joined' makes some
> sense.  But sometimes you don't want to load relationships.  In those
> cases query.enable_eagerloads(False) is very useful.
> 
> However, often you do want to load *some* relationships, but the rest
> you want "turned off" without having to enumerate them manually.  You
> can't use enable_eagerloads(False) because there are a couple you want
> to specify.
> 
> Have you considered a public query API for what is similar to the
> framework's query._only_load_props, except that it would work off just
> relationship properties (and leave column properties alone)?
> 
> I've come across this several times now and I find it awkward to need
> to enumerate all the joined_loads and turn them off manually with
> query.options(lazyload()).  Suggestions?
> 

I leave lazy=True in almost all cases, except for some that i use subqueryload, 
then use options(whatever) to "joinedload" whatever i want to load that way.   
But I only use joinedload for many-to-ones, which in an equal number of cases 
I'm already joining to via join(), in which case I use contains_eager().   So 
there's virtually no case i want joinedload() on by default.

joins are expensive when there's too many of them, so these days I never want 
to specify joinedload() in any other way other than within options().

that said, if there's a set of six different relationships you like to 
joinedload() a lot, you can build a function that just spits them 
out....query.options(*standard_joined_loads().minus(i_dont_want_these)) type of 
thing....I've used that approach for setting up caching options in the past.






> Thanks,
> Kent
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> To unsubscribe from this group, send email to 
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sqlalchemy?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to