Last active
August 29, 2015 14:25
-
-
Save exit99/cb2d58234485310c7486 to your computer and use it in GitHub Desktop.
SQLA Alchemy exists speed test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Assume `Ticket.query` == session.query(Ticket). | |
This is done a table with 400,000+ rows and 0-40 rows where there is identical client_id fields. | |
1. bool(Ticket.query.filter_by(client_id=1111).count()) | |
2. Ticket.query.with_entities(exists().where(Ticket.client_id == 1111)).scalar() | |
Results | |
1. 2. | |
20584 10622 | |
25934 7449 | |
20154 8009 | |
23342 7439 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment