我在远程服务器上有2个非常大(数十亿行)的展开表Trades
和StockPrices
。我想做一个asof join
h:hopen `:RemoteServer:Port
h"aj[`Stock`Date`Time,
select from Trades where Date within 2014.04.01 2014.04.13,
StockPrices
]"
但我得到错误(我{m Studio for KDB+)
An error occurred during execution of the query.
The server sent the response:
splay
Studio Hint: Possibly this error refers to nyi op on splayed table
那么进行这种连接的正确方法是什么?
此外,性能和效率是一个问题有这样一个大表 - 我应该怎么做才能确保查询不需要花费数小时而且不会消耗太多服务器的系统资源?
答案 0 :(得分:4)
您需要将展开的StockPrices
表映射到内存中。这可以通过使用select
查询来完成:
q)(`::6060)"aj[`sym`time;select from trade;quote]" / bad
'splay
q)(`::6060)"aj[`sym`time;select from trade;select from quote]" / good
sym time prx bid ask
-------------------------------------------
aea 01:01:16.347 637.7554 866.0131 328.1476
aea 01:59:14.108 819.5301 115.053 208.1114
aea 02:42:44.724 69.38325 641.8554 333.3092
此页面可能对查找Kdb +中的错误非常有用:http://code.kx.com/q/ref/error-list/
关于优化aj
的效果,请参阅http://code.kx.com/q/ref/joins/#aj-aj0-asof-join
此外,如果天数之间没有数据重叠,则可能更快地逐日运行查询,可能并行。
如果几天内数据重叠,请合并日期和时间。时间列到单个时间戳列中会加快查找速度。