【问题标题】:Cassandra Cql schema best practiceCassandra Cql 架构最佳实践
【发布时间】:2015-07-13 12:30:58
【问题描述】:

在这里我得到一个很好的解释后再次问类似的问题 How do secondary indexes work in Cassandra?

CREATE TABLE update_audit (
  scopeid bigint,
  formid bigint,
  time timestamp,
  operation int,
  record_id bigint,
  ipaddress text,
  user_id bigint,
  value text,
  PRIMARY KEY ((scopeid), formid, time)
  ) WITH CLUSTERING ORDER BY (formid ASC, time DESC)

仅供参考, 操作列可能的值为 1,2 和 3。低基数。

record_link_id 高基数。每个条目都可以是唯一的。

根据How do secondary indexes work in Cassandra?The sweet spot for cassandra secondary indexing.

user_id 是索引的最佳候选者

搜索应该基于

  • 时间,限制为 100。
  • 操作时间,限制为 100。
  • user_idtime 限制为 100。
  • record_id 和时间限制为 100。

问题

总记录超过 10,000M

哪个最好 - 创建 Index over operationuser_idrecord_id 并应用限制 100。

  1) Does Hidden columnfamily for index operation Will return only 100 results?

  2) More seeks will slow down the fetch operation?

OR 创建一个新的列族,其定义类似于

CREATE TABLE audit_operation_idx (
  scopeid bigint,
  formid bigint,
  operation int,
  time timeuuid,
  PRIMARY KEY ((scopeid), formid, operation, time)
) WITH CLUSTERING ORDER BY (formid ASC, operation ASC, time DESC) 

 required two select query for single select operation.

所以,如果我要为 operationuser_idrecord_id 创建新的 columnfamily

我必须进行批量查询才能插入到这四个列族中。

   3) Does TCP problems will come? while executing batch query.because writes will be huge. 
   4) what else should I cover to avoid unnecessary problems. 

【问题讨论】:

    标签: cassandra datastax cql3 cqlsh cassandra-jdbc


    【解决方案1】:

    共有三个选项。

    1. 创建一个新表并使用批量插入。如果插入查询的大小变得很大,则必须配置其相关参数。不用担心在 Cassandra 中的写入。

    2. 创建具有 where 子句所需列的物化视图。

    3. 如果基数较低,则创建二级索引。 (不推荐)

    【讨论】:

      猜你喜欢
      • 2013-01-04
      • 2020-06-12
      • 2010-11-17
      • 1970-01-01
      • 2020-07-13
      • 2013-05-07
      • 2022-01-16
      • 2010-10-22
      • 1970-01-01
      相关资源
      最近更新 更多