通过python脚本每秒测量clickhouse查询

问题描述

查询有两部分 -

  1. 为什么 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为什么差别这么大?

  1. 如何在python中测量每秒查询次数

    假设我必须衡量我可以在 1 中运行多少个 select * 查询 第二。我做了什么来衡量它 -

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 (将#修改为@)