如何高效取某个股票的最后35000行高频行情数据?

某个股票的数据大约300W行,已经取到内存了,具体如下:

attachments-2022-10-xJf1mV9i635923c02bd56.png

请问如何高效取某个股票的最后35000行高频行情数据?

请先 登录 后评论

1 个回答

Jason Tang - 时序数据库技术支持

针对上述场景,这边给出两种查询方案:

def createData(num){
	date = take(2022.01.01, num)
	time = 00:00:00.000 + take(0..num, num)
	a1 = rand(1000, num)
	a2 = rand(1000, num)
	a3 = rand(1000, num)
	a4= rand(1000, num)
	a5 = rand(100.0, num)
	a6 = rand(100.0, num)
	a7 = rand(100.0, num)
	a8 = rand(100.0, num)
	return table(date, time, a1, a2, a3, a4, a5, a6, a7, a8)
}
num = 3000000
t = createData(num)

//方法1
timer{
	result = (select * from t order by time desc limit 35000).sortBy!(`time)
}
//Time elapsed: 11.732 ms

//方法2
timer{
	rowOffset = size(t) - 35000
	rowCount = 35000
	result = select * from t order by time limit rowOffset, rowCount
}
//Time elapsed: 14.013 ms
请先 登录 后评论
  • 1 关注
  • 0 收藏,773 浏览
  • Xinhai Tang 提出于 2022-10-26 20:10

相似问题