On 12/01/2016 11:49 AM, Adrian wrote:
`from_self().exists()` seems to produce an unnecessarily complex query
(still containing all the original columns)
also please see the source for count() re: the original columns:
col = sql.func.count(sql.literal_column('*'))
return self
On 12/01/2016 11:49 AM, Adrian wrote:
`from_self().exists()` seems to produce an unnecessarily complex query
(still containing all the original columns)
it is unnecessarily complex in some situations but in others it is not.
count() for many years tried to guess which situations it could do
`from_self().exists()` seems to produce an unnecessarily complex query
(still containing all the original columns)
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Ex
if it works like count(), then it would be making use of from_self()
which disables eager loads already.
On 12/01/2016 09:47 AM, Adrian wrote:
Would you be interested in a PR adding `Query.row_exists()` or even
`Query.row_exists(disable_eagerloads=True)` which would also disable
eagerloads by d
Would you be interested in a PR adding `Query.row_exists()` or even
`Query.row_exists(disable_eagerloads=True)` which would also disable
eagerloads by default?
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide
On 12/01/2016 09:37 AM, Adrian wrote:
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):
I would have assumed you had some filtering condition.
Checking an EXI
> 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
db
On 12/01/2016 09:13 AM, Adrian wrote:
Is there any shorter/prettier way for this?
session.query(session.query(Foo).exists()).scalar()
I would normally do
session.query(Foo).count()
I've never embedded an EXISTS like that.
It's not hard to add a custom method to the base query cla