2016-09-21 79 views
1

我想在Cassandra中使用行緩存,但我不明白它是如何工作的。 我已經啓用的cassandra.yaml(2GB分配)行高速緩存,並改變了架構:Cassandra和行緩存

ALTER TABLE d 
with caching = { 
    'keys' : 'ALL', 
    'rows_per_partition' : '36000' 
}; 

鍵緩存正常工作,我有90%的命中率,而行高速緩存我看到這些從nodetool info號:

Row Cache : entries 2, size 2 bytes, capacity 1.95 GB, 1620 hits, 39699640 requests, 0.000 recent hit rate, 0 save period in seconds 

正如你所看到的,高速緩存只包含2項,而我已經在該表上的所有條目進行4M +查詢。

有什麼想法?我應該調查什麼才能理解爲什麼不使用行緩存?

更新1 感謝Chris,我已經重新與row_cache_save_period = 14400組,但我認爲沒有變化。

Row Cache : entries 0, size 0 bytes, capacity 1.95 GB, 0 hits, 85098 requests, 0.000 recent hit rate, 14400 save period in seconds 

更新2 下面是模式定義:

CREATE TABLE d_t (
    id bigint, 
    xid bigint, 
    ts timestamp, 
    avg double, 
    ce double, 
    cg double, 
    p double, 
    w double, 
    c double, 
    sum double, 
    last double, 
    max double, 
    min double, 
    p75 double, 
    p90 double, 
    p95 double, 
    squad double, 
    sumq double, 
    wavg double, 
    weight double, 
    PRIMARY KEY ((id), xid, ts) 
) WITH CLUSTERING ORDER BY (xid DESC, ts DESC) 
and compaction = {'class': 'SizeTieredCompactionStrategy'} 
and gc_grace_seconds=86400 
and caching = { 'keys' : 'ALL', 'rows_per_partition':'36000' } 
and min_index_interval = 2 
and max_index_interval = 20; 

更新3

使用卡桑德拉3.0.9

回答

0

我明白了。爲其他用戶共享。 3.0.x行緩存實現中存在一些錯誤,最常遇到的問題是「按順序排序」子句。刪除命令後,行緩存開始工作。我已經在3.9上測試過了。 但是,行緩存用於iif where條件只包含分區鍵。如果指定了羣集列上的過濾器,則不評估高速緩存。 這真的很奇怪,但就是這樣。這裏有更多的細節:https://issues.apache.org/jira/browse/CASSANDRA-8646

2

您設置row_cache_size_in_mb選項。您還需要設置row_cache_save_period,您有0(默認)。這將禁用它。這在消息的0 save period in seconds部分中顯示。

+0

謝謝。我改變了這個參數並重新啓動了集羣,但仍然是同樣的行爲。 '行緩存:條目0,大小爲0字節,容量爲1.95 GB,點擊次數爲0,請求次數爲85098,最近命中率爲0.000,保存期限爲14400秒 – RJtokenring

+0

是否可以包含有問題的架構和版本?你周圍可能會碰到一些問題,如https://issues.apache.org/jira/browse/CASSANDRA-12499 –

+0

添加了模式定義。謝謝。使用cassandra 3.0.9 – RJtokenring