编辑: VS代码玩得不好。我在Jupyter中运行了完全相同的代码,它工作得更快。
我坚持使用32位Python,因为数据库是32位的。我不知道这是否会影响查询的速度,但它确实会造成内存问题,所以我想在这里提到它。
我注意到,当在Oracle SQL Developer中运行查询时,它比我通过python连接到数据库并运行查询快20%-30%。作为自动化过程的一部分,我使用pandas将结果导出到csv,否则我将手动从Oracle导出结果。
import cx_Oracle as cx
import pandas as pd
dsn_tns = cx.makedsn('server_name', 'port', service_name='service_name')
conn = cx.connect(user=config.username, password=config.password, dsn=dsn_tns)
cursor = conn.cursor()
f = open('.sql file path', 'r')
sql = f.read()
f.close()
pd.read_sql_query(sql, conn)这很简单,它是有效的,但它比在Oracle中运行我的查询慢得多。
我的问题是,为什么?我怎样才能提高速度?
发布于 2021-03-04 05:56:53
总结各种评论:
请遵循手册:https://cx-oracle.readthedocs.io/en/latest/user_guide/tuning.html中的
发布于 2021-03-04 22:13:43
VS Code给了我这个问题。我使用了Jupyter,它工作得很好,而且速度更快。
https://stackoverflow.com/questions/66443439
复制相似问题