pandas.read_sql is extremely slow on python 3 kernel compared to python 2

726 Views Asked by At

I have a simple parameterized select query hitting an Oracle database via pyodbc connection and fetching data in a dataframe via pandas.read_sql. The code is super efficient and fast in Python 2 kernel whereas, extremely slow in Python 3.

Following is the code:

import pandas
import pyodbc
import time

connection = pyodbc.connect('dsn=oracle;userid=userid;pwd=password')
sql = """
select * from order_table
where 
order_key = ?
"""
start_time = time.time()
dataframe = pandas.read_sql(sql=sql, con=connection, params=['key-1'])

print(time.time()-start_time)

Python 2 execution time: 0.193000078201

Python 3 execution time: 53.687000036239624

0

There are 0 best solutions below