Navicat花费42秒执行查询,而python花费80秒钟甚至90多个
这是我正在使用的代码:
server = SSHTunnelForwarder(
(bastion_host, 22),
ssh_username=ssh_username,
ssh_password=ssh_password,
remote_bind_address=(sql_serverhost, 3306))
server.start()
conn = db.connect(host=localhost,
port=server.local_bind_port,
user=sql_user,
passwd=sql_password,
db=database)
mydb=create_engine('mysql+pymysql://' + sql_user + ':' + sql_password + '@' + localhost + ':' + str(server.local_bind_port) + '/' + database , echo=False)
a=dt.datetime.now()
d=pd.read_sql_query("SELECT * FROM table WHERE DATE(Date)>='2018-01-01'", conn)
b=dt.datetime.now()
c=b-a
server.stop()