Hello all, 
Hope you are fine and safe in these times!

I can be easily considered as a novice in SQLAlchemy.
I am trying to pull data from a MYSQL database from a table having around 
20 columns and more than 10 million rows. 
The table is partitioned and indexed. I am using a complex query, having 
UNION of multiple sub-queries, in the format:

with cte1 as <subquery1>, 
cte2 as <subquery2>, 
.. 
select * from cte1
union all
select * from cte2
;

The code demands it to be a dynamic query and number of sub-queries depends 
on the user input. 
For understanding purpose, I took a query having two sub-queries. 
So, when I passed the query to MySQL directly, it took very less time 
(around 0.016 seconds) but when I passed the same 
query through SQLAlchemy connector, it took around 600 seconds.
I tried generating the query using only text clause in one approach and I 
also tried combination of .select(), .where() and .and_ query approach.
However, both were taking a very long time.

I am not sure what can be issue. It'll be great if I can get any pointers 
to reduce the time, preferably under 10 seconds!

Thanks in advance!

Regards,
Saylee

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/f7b03dcd-dd38-4df1-8719-a7902b1a39d4o%40googlegroups.com.

Reply via email to