如何获取CQL查询的墓碑计数?

14

我正试图评估我们应用程序中一个表中创建的墓碑数量。为此,我正在尝试使用nodetool cfstats。以下是我的做法:

create table demo.test(a int, b int, c int, primary key (a));
insert into demo.test(a, b, c) values(1,2,3);

现在我正在制作与上述相同的插入。因此,我希望会创建3个墓碑。但是,在运行此列族的cfstats时,我仍然看到没有创建任何墓碑。

nodetool cfstats demo.test
Average live cells per slice (last five minutes): 0.0
Average tombstones per slice (last five minutes): 0.0

现在我尝试删除记录,但仍然没有看到任何墓碑被创建。这里有什么我错过的东西吗?请建议。

顺便提一下其他一些细节, * 我们正在使用Java驱动程序的2.1.1版本 * 我们正在运行针对Cassandra 2.1.0


顺便提一下,Cassandra 2.x和1.x在持续清除墓碑方面存在问题(即在启动时可以正常运行,但一段时间后会完全停止)。 - Alexis Wilke
我的看法是,cfstats 命令使用的数据更新速度不够快,你不会在删除后立即看到变化。也许等待一分钟,或者使用 RussS 的解决方案会更好。 - Alexis Wilke
1个回答

29

如果要查询墓碑计数,最好的方法是启用跟踪。这将为您提供查询的详细历史记录,包括完成查询需要读取多少墓碑。虽然无法给出总墓碑计数,但对于性能调优可能更加相关。

在cqlsh中,您可以使用以下命令启用此功能:

cqlsh> tracing on;
Now tracing requests.
cqlsh> SELECT * FROM ascii_ks.ascii_cs  where pkey = 'One';

 pkey | ckey1 | data1
------+-------+-------
  One |   One |   One

(1 rows)


Tracing session: 2569d580-719b-11e4-9dd6-557d7f833b69

 activity                                                                 | timestamp    | source    | source_elapsed
--------------------------------------------------------------------------+--------------+-----------+----------------
                                                       execute_cql3_query | 08:26:28,953 | 127.0.0.1 |              0
 Parsing SELECT * FROM ascii_ks.ascii_cs  where pkey = 'One' LIMIT 10000; | 08:26:28,956 | 127.0.0.1 |           2635
                                                      Preparing statement | 08:26:28,960 | 127.0.0.1 |           6951
                             Executing single-partition query on ascii_cs | 08:26:28,962 | 127.0.0.1 |           9097
                                             Acquiring sstable references | 08:26:28,963 | 127.0.0.1 |          10576
                                                Merging memtable contents | 08:26:28,963 | 127.0.0.1 |          10618
                                              Merging data from sstable 1 | 08:26:28,965 | 127.0.0.1 |          12146
                                              Key cache hit for sstable 1 | 08:26:28,965 | 127.0.0.1 |          12257
                                                    Collating all results | 08:26:28,965 | 127.0.0.1 |          12402
                                                         Request complete | 08:26:28,965 | 127.0.0.1 |          12638

Tracing in Cassandra 1.2


14
谢谢RussS的回复。但是我真的不明白追踪的哪一部分实际上涉及到读取的墓碑数量。你能否请提供更多细节? - Prasanth
1
您还可以从nodetool cfstats获取每个切片的平均墓碑数量(最近五分钟)。 - phact
是的,但那并不起作用。这就是为什么RussS建议打开查询跟踪的原因。 - Prasanth
8
@PrasanthNath:答案的示例中没有展示出来,但跟踪输出将具有墓碑信息,例如:Read 101 live and 85 tombstone cells [SharedPool-Worker-4] | 2015-07-29 14:57:36.895000 | 192.168.12.93 | 25264 - 8forty
1
那么为什么跟踪输出中没有显示墓碑呢? 就像@PrasanthNath在他的原始问题中建议的那样,我期望在跟踪输出中看到3个墓碑。 - actf
1
大家,只需运行一些“nodetool cfstats keyspace | tee tombstone.txt”,分析内容并识别带有墓碑的表。启用跟踪,运行像RussS`这样的查询,您将在跟踪输出中注意到读取过程如何发生,实际解析多少墓碑以满足查询。 - Mr'Black

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接