首页 > 解决方案 > 如何在 kdb 中的分区表上应用 asof 连接

问题描述

我需要对已分区的贸易和报价表的几年数据运行 asof join。
当我通读 - https://code.kx.com/v2/ref/aj/ 上面的网址指出 -

"If further where constraints are used, the columns will be copied instead of mapped into memory, slowing down the join."

如何在不影响性能或内存的情况下使用 asof 连接具有日期和其他约束的分区数据库。

Eg: aj[`sym`time;select from trade where date>2019.01.01, app=`abc; select from quote where date>2019.01.01]

标签: kdb

解决方案


你应该做date=并运行each/peach日期而不是做date>,即

raze{aj[`sym`time;select from trade where date=x, app=`abc;select from quote where date=x]}peach 2019.01.01 2019.01.02 2019.01.03

通常可以接受额外的交易过滤器,但可能仅当该列app具有 parted 属性时。您不能在报价或性能坦克上使用任何过滤器。

请注意,使用这种方法,您无法将前一天的流行数据加入到第二天,但在大多数情况下,您无论如何都不想/不需要这样做


推荐阅读