我想創建一個卡桑德拉列族與外地(time_partition,鑰匙,PERIOD_TIME和period_value存儲時間序列數據。
我使用time_partition用於快速查詢。 time_partition = PERIOD_TIME /(的EPOCH WEEK);哪個列族方法在cassandra中是可取的?
哪一列家庭創造更好的(我有大量的數據太)
方法1
CREATE TABLE tablename
(
time_partition text,
key text,
period_time text,
period_value text,
PRIMARY KEY (time_partition,key, period_time)
);
方法2
CREATE TABLE tablename
(
key text,
time_partition text,
period_time text,
period_value text,
PRIMARY KEY (key,time_partition, period_time)
);
2種方法之間的區別在於主鍵的順序。
我只想這樣查詢: (對於第一種方法)select * from tablename where time_partition = and key = and period_time = ;或 (對於第二種方法)select * from tablename where key = and time_partition = and period_time = ; 在獲取數據方面速度都一樣嗎? –
kjk
分區的大小也會影響讀取性能。所以如果''鍵的數量很少,那麼你最終會得到大的分區。 您可以使用複合分區鍵「PRIMARY KEY((key,time_partition),period_time)」,因此每個物理分區只會存儲「period_time」值。但是你不能通過''key''和''time_partition''來命令它 –