On Apr 24, 2007, at 4:27 AM, Andreas Jung wrote:

>
> Because both tables are big the query takes forever. Using a LEFT JOIN
> would definitely be faster. Is there a way to configure the 'tools'
> property in a smarter way?
>

not within the relation(), we dont support self-referential eager  
loads automatically.

you can however construct whatever query you want using select(), and  
use it via query.select(myselect) or query.instances(myselect.execute 
()).  to affect eager loading from such a call, use the  
"contains_eager()" query option.  see the example in the "advanced  
data mapping" docs for an example of contains_eager()...it would be  
sometihng along the lines of:

node_table_alias = node_table.alias('foo')
s = select([node_table, node_table_alias],  
node_table.c.node_id==node_table_alias.c.parent_id)

result = session.query(HierarchyNode).contains_eager('tools',  
alias=node_table_alias).select(s)


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to