Hi, 

I use SQLalchemy 0.7.9 with SQLite and have a performance issue. 
I have a simple database with joined table inheritance and some 
relationships. In short: I have a base class Human, and 3 subclasses (Men, 
Woman and Child), and I have a class House. 
The house class have a many to many relationship to the human class (a 
house have residents, and every human have houses). 
And there are two more relationship, the Woman and the Men class have a 
many to many relationship to the Child class (a men/woman can have many 
children).
Here you can see my model , query code: http://pastebin.com/mcum0c7Q

The issue is: if I load a house from the database with house = 
session.query(House).first() and then access the residents of this house 
with "house.residents",
and iterate over the residents and access the children of every resident 
then sqlalchemy emits a new sqlquery on every access: 
for resident in house.residentes: 
print resident.myChildren # emits new sql-query

This is very bad for my performance, what I need is a solution, that load 
with a single "session.query(House)-Command" all residents AND all children 
of the residents at once!
Is this possible? 
For the many to many relationship between the Women/Men and the Child class 
is use lazy='subquery', but sqlalchemy ignore this! Why? 

I hope someone could help me.




-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/__1nn279L1EJ.
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