> I would normally do session.query(Foo).count()

COUNT is somewhat expensive compared to just checking whether rows exist, 
especially if lots of rows match (2.2M rows in the example):

In [2]: %timeit -n1 -r1 EventPerson.query.count()
1 loop, best of 1: 135 ms per loop
In [3]: %timeit -n1 -r1 
1 loop, best of 1: 2.44 ms per loop

> how does this interact with filtering etc?

It keeps all the filters present on the query object (in that example, 
`self` is the existing query object)

> this query is against column expressions, not entities, so eager loading 
is not involved.
That's what I first thought, but the related OUTER JOINs are still added. 
Maybe a bug?

SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper


To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
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 https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to