Hi Kadler,
I am using ibm_db_sa+pyodbc dialect. Also I have tried this with 3 drivers IBM i Access ODBC Driver, iSeries Access ODBC driver and Client Access ODBC Driver(32 bit). Version of all drivers - 13.64.22.00
I have checked the connection string with 'Performance' keyword as well as other few keywords.But there is no difference in time. I got this performance issue for 5M records too. JDBC takes 10-12 seconds and ODBC driver takes 30-35 Minutes to execute the same query. But surprisingly if table row count is around 2M records , then JDBC and ODBC takes same time ( less than 2 secs).
My few Observations that might help you to diagnose the issue:(Observations done on 3 different databases, which are located in 3 different geographical regions.)
1)When I analyse the query stats in running jobs tool on I series navigator, I saw that when I am submitting the query using ODBC driver,that stats get updates around 6-8K records by per second but in the case of JDBC, around 85-90K stats get updated per second which I found strange behaviour from the database.
2) Another observation is , when I analyse the query in running jobs tool on I series navigator, I series navigator not allow me to see query execution details for the query which executed by ODBC driver but it allow to see query execution for JDBC driver queries.( this observation I have mentioned just FYI).
I will create some POCs as you mentioned above and share with you within few hours.