计算cassandra中的分区大小

时间:2016-06-10 11:34:54

标签: cassandra

我正在Cassandra实施独特的入境柜台。计数器可以表示为一组元组:

counter_id = broadcast:12345, token = user:123
counter_id = broadcast:12345, token = user:321

其中,计数器broadcast:12345的值可以计为相应条目集的大小。这样的计数器可以有效地存储为counter_id作为分区键的表。我的第一个想法是,由于单个计数器值基本上是分区的大小,我可以进行count(1) WHERE counter_id = ?查询,这不需要读取数据并且可以超级快速。但是,我看到以下跟踪输出:

 cqlsh > select count(1) from token_counter_storage where id = '1';


 activity                                                                                        | timestamp                  | source     | source_elapsed
-------------------------------------------------------------------------------------------------+----------------------------+------------+----------------
                                                                              Execute CQL3 query | 2016-06-10 11:22:42.809000 | 172.17.0.2 |              0
        Parsing select count(1) from token_counter_storage where id = '1'; [SharedPool-Worker-1] | 2016-06-10 11:22:42.809000 | 172.17.0.2 |            260
                                                       Preparing statement [SharedPool-Worker-1] | 2016-06-10 11:22:42.810000 | 172.17.0.2 |            565
                 Executing single-partition query on token_counter_storage [SharedPool-Worker-2] | 2016-06-10 11:22:42.810000 | 172.17.0.2 |           1256
                                              Acquiring sstable references [SharedPool-Worker-2] | 2016-06-10 11:22:42.810000 | 172.17.0.2 |           1350
 Skipped 0/0 non-slice-intersecting sstables, included 0 due to tombstones [SharedPool-Worker-2] | 2016-06-10 11:22:42.810000 | 172.17.0.2 |           1465
                                Merging data from memtables and 0 sstables [SharedPool-Worker-2] | 2016-06-10 11:22:42.810000 | 172.17.0.2 |           1546
                                        Read 10 live and 0 tombstone cells [SharedPool-Worker-2] | 2016-06-10 11:22:42.811000 | 172.17.0.2 |           1826
                                                                                Request complete | 2016-06-10 11:22:42.811410 | 172.17.0.2 |           2410

我猜这条跟踪确认数据是从磁盘读取的。我是否在这个结论中,如果是的话,有没有办法简单地使用索引获取分区大小而没有任何过多的磁盘命中?

0 个答案:

没有答案