Cassandra Cql架构的最佳实践

时间:2015-05-04 07:27:21

标签: cassandra datastax cql3 cqlsh cassandra-jdbc

在我得到一个很好的解释之后,我再次提出类似的问题 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)

FYI, 操作列可能的值为1,2和3.低基数。

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

根据{{​​3}}和How do secondary indexes work in Cassandra?

user_id 是索引的最佳候选人

搜索应该基于

  • 时间,限额为100。
  • 操作时间,限制为100。
  • user_id 时间,限制为100。
  • record_id ,时间限制为100。

问题

总记录超过10,000M

哪一个是最好的   - 创建操作指数 user_id record_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.

所以,如果我要为操作 user_id record_id

创建新的列系列

我必须进行批量查询以插入这四个列家族。

   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. 

1 个答案:

答案 0 :(得分:0)

有三种选择。

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

  2. 使用where子句的必需列创建实体化视图。

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

相关问题