2015-05-04 28 views
1

在這裏,我對 How do secondary indexes work in Cassandra?卡桑德拉CQL架構最佳實踐

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高基數。每個條目都可以是唯一的。

user_id說明是根據How do secondary indexes work in Cassandra?The sweet spot for cassandra secondary indexing.

搜索索引的最佳候選人應該工作基於

  • 時間與限100
  • 操作時間限制爲100.
  • user_id說明時間與限100
  • RECORD_ID和時間與限100

問題

總記錄多於萬兆

其中一個最好是 - 創建操作索引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? 

創建一個新的ColumnFamily與像

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. 

定義所以,如果我會爲操作創造新的ColumnFamily ,user_id and 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. 

回答

0

有三種選擇。

  1. 創建一個新表並使用批量插入。如果插入查詢的大小變得很大,則必須配置其相關參數。不要擔心卡桑德拉的寫作。

  2. 使用where子句的必需列創建物化視圖。

  3. 如果基數較低,則創建二級索引。 (不推薦)