问题描述
查询有两部分 -
-
为什么 cli 查询客户端执行速度比 python 驱动客户端快?
我使用 Clickhouse 数据库和 driver 来触发 Python 中的查询。我正在运行超过 170K+ 行的查询
select * from <table> where id = <some_id> and trans_date < <some date>
。因此,当我使用clickhouse-client
(类似于 Postgres 中的psql
)cli 来触发查询时,它需要60 milliseconds
。当我使用上面的驱动程序通过 python 触发时相同的查询,如下所示 -
from clickhouse_driver import Client
from time import time
...
client = Client({server_configurations})
...
start = time()
client.execute(select * from <table> where id = "some_id" and trans_date < "some date")
print(time() - start) // 150 milliseconds
它大约是 150 milliseconds
。 为什么差别这么大?
start = time()
count = 0
while time() - start <= 1:
client.execute(("SELECT * FROM <table> WHERE id = 'some_id' AND trans_date < 'some_date' LIMIT 100"))
count += 1
print("count--->",count) // Number of queries ran
有没有更好的方法来衡量它? python 中的任何工具或模块可以帮助我吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)