Hi all, I'd like to ask for your help with implementing the following.
I have quite a complex query with subqueries generated in the application. In general the structure would look like this: draft_data = aliased( Draft.query.filter( Draft.author_user_id == drafts_from_user_id # draft_from_user_id is a bind parameter ).subquery(), name='draft_data' ) then a bunch of similar subqueries that get integrated into the main query like this: query = query.outerjoin(draft_data, WorkItemData.draft_id == draft_data.c.id) The actual query has around six parametrized subqueries like this. The resulting query is pretty fast, but it's compilation takes about 50% to 100% time of its execution => I decided to go with the BakedQuery. However from the BakedQuery documentation I could not figure out how I should use it with joins / subqueries. Should I BakedQuery subqueries separately and then somehow join them with the main BakedQuery (how?). Should I somehow do the BakedQuery only of the main query (what to do with subqueries then?). Thank you for any help, Anton -- 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 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.