I think I've seen this sort of functionality in Hibernate, where it tries 
to optimize if you are going to access some lazy loaded property on a 
collection of objects. It can load them in batches, as opposed to one query 
for every object. 

So, I'm asking if there is any way to do something like this in SQL 
alchemy, either implicitly or explicitly? Say I've queried a number of 
Parent objects, and somewhere later on, I want to show the (lazy loaded) 
child objects of these parents. If I have a 1000 of these parent objects, 
it might not be desirable to do 1000 queries to display these child objects 
for every parent. If I've already loaded a list of entities in SQLAlchemy, 
is there a way to batch load a lazy relationship for every entity in the 
list?

Example:
1) define Parent has relationship(Child)
2) query 1000 Parents (possibly using filters and limit and order by)
3) pass 1000 Parents to some function that loads all Child relationships 
for each Parent with a second single query

I know I could use joinedload or subqueryload to eager fetch these, but it 
does not work on our database (an old version of Sybase 12). There may also 
be some other use case for not eager loading these kinds of relationships 
at query time, hence why I'm asking.

-Kevin

-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to