taosdata / taos-connector-python

TDengine connector for Python
https://www.taosdata.com/cn/documentation/connector#python
MIT License
48 stars 14 forks source link

taospy 获取 tdengine的查询数据的速度异常 #215

Closed markcheney1 closed 1 year ago

markcheney1 commented 1 year ago

系统:

  1. 客户端所在系统:Ubuntu 20.04.5 LTS
  2. 服务端所在系统:Ubuntu 20.04.5 LTS

软件版本:

  1. taospy:2.7.10
  2. tdengine:3.1.0.0
  3. taos客户端:3.1.0.0

配置:

  1. vgroups为8
  2. 去读的表算上stable的tags,一共有9个字段

使用的代码:

import taos

td_conn_local = taos.connect(host="127.0.0.1",
                     user="root",
                     password="taosdata",
                     database="test",
                     port=6030,
                     config="/etc/taos",  # for windows the default value is C:\TDengine\cfg
                     timezone="Asia/Shanghai") 
import time
now = time.time()
query = td_conn_local.query("select * from k1 limit 1000000").fetch_all_into_dict()
print(time.time()-now)

运算时间:20.743690967559814 s

切换golang的连接器: 运行时间约为3s

问题:

  1. taospy是否没有多线程数据拉取,有没有计划做?
  2. taospy正常拉取数据的基准速度是多少?
sangshuduo commented 1 year ago

连接器只提供接口简单封装,内置不实现并发机制,需要应用自己处理并发

Python 语言不以性能见长,这个结果不意外,你可以拿 go 和 python 跳过 taos 接口构造数据测试模拟一下语言层面的性能差异

markcheney1 commented 1 year ago

连接器只提供接口简单封装,内置不实现并发机制,需要应用自己处理并发

Python 语言不以性能见长,这个结果不意外,你可以拿 go 和 python 跳过 taos 接口构造数据测试模拟一下语言层面的性能差异

尝试过了,在调用taos库获取的数据,速度是正常的,确实是cast花费了大量时间

hadrianl commented 1 year ago

try not use fetch_all_into_dict, use fetch_all instead

hadrianl commented 1 year ago

I`m working on this with my enh/cython branch

markcheney1 commented 1 year ago

I`m working on this with my enh/cython branch

  • involve connection, cursor, result, schemeless_insert, statement, consumer
  • more pythonic, faster, using cython
  • code work was almost done, hopefully som day, it might be merged into main branch
  • but now, more test is needed

Sounds awesome. Can't wait to try it out