If you want to count the children of a parent entity you can do it
like that:

    parent.children.count(Child.id)

Generally, this is fine. But it loads all children into the session
and then "manually" counts them.
For large sets this will become very slow.

Wouldn't it be smarter to do the count in the database, as it would be
done with the following query?

 
session.query(Child).filter(Parent.id==Child.parent_id).count(Child.id)

Currently I have to implement a children_count() method in the parent
to avoid loading all the children from the database.
--~--~---------~--~----~------------~-------~--~----~
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