1

我听说从 HDB 和 RDB(内存中)数据库查询(选择等)时存在差异。当我们应该使用 HDB 特定查询和 RDB 特定查询以及如何查询时,是否可以描述所有可能的场景:即 HDB 查询示例和 RDB 相同示例?

4

3 回答 3

5

If you are using a vanilla rdb/hdb set up then this is the scenario:

  • tickeplant collects data for x millis and pumps to listeners
  • rdb is one such listener. It will hold data from midnight today to just before midnight tonight
  • at midnight tickerplant sends .u.end message
  • this invokes rdb to dump the in-memory table onto disk inside a 2014.12.19/ directory
  • note that the schema on an rdb is time, sym, then other columns. On hdb this switches to date (virtual), sym (p attr), time (sorted within sym)

So your where clause criteria is:

  • If you need to query data for today, it's rdb
  • anything before today, it's hdb
  • anything mixed, create functions on your hdb that pull data from rdb and join

The most optimal query for an rdb is always

select from table where time ...

because the rdb table is time sorted.

The most optimal query for an hdb is always

select from table where date=2014.12.24, sym=`AAPL, time ...

because it reduces seeks to disk (only needs to check data in 2014.12.24 directory), is sym parted and then time sorted within sym (altho technically there is no s attribute obviously). Having date as the first part of your where clause is very important! :)

于 2014-12-19T08:54:14.080 回答
3

在我的头顶上:

分区的 HDB 表将有一个“虚拟”日期列

RDB 表(通常)不会有 `date 列

对于分区 HDB 表,虚拟“i”列的行为不同(http://code.kx.com/q/ref/dotq/#qind-partitioned-index

HDB 表(除非存储平面/序列化)不会立即完全拉入内存,数据是按需读取的

HDB表中的符号列将被枚举,内存中的RDB表将不被枚举

我无法提供真实的示例,但您只需要在查询时牢记这些

于 2014-12-18T20:30:23.557 回答
0

到目前为止,我遇到了以下在 hdb 中不起作用的示例查询。

  1. 计算表名
  2. 从表名中选择 [10]
  3. 在 hdb 重新启动之前,删除/更新/插入语句仅具有临时效果

当我遇到更多时,我会更新这个列表

于 2016-04-14T13:30:08.407 回答