首页 > 解决方案 > 检查 Cassandra 中哪些表是空的

问题描述

我需要通过几个键空间检查 Cassandra 中哪些表是空的,并且有超过 20 个表。我可以对每张桌子进行计数,但这有点麻烦......

有没有办法在不输入所有 20 多个查询的情况下查看不同键空间中每个表的计数?如果有帮助,我会将表格放在逗号分隔的列表中。

编辑:我使用 python 来帮助解决这个问题,但对 Cassandra 解决方案感兴趣。

标签: cassandra

解决方案


您也可以在命令行级别尝试nodetool tablestats

» bin/nodetool tablestats stackoverflow | grep "Table\:\|partitions"
        Table: cart_product
        Number of partitions (estimate): 1
        Table: keyvalue
        Number of partitions (estimate): 0
        Table: last_message_by_group
        Number of partitions (estimate): 2
        Table: mytable
        Number of partitions (estimate): 5
        Table: temps_by_item
        Number of partitions (estimate): 2
        Table: users
        Number of partitions (estimate): 1

当然,这仅反映命令所在的节点。但是您应该能够通过此或tablestats输出中可用的其他几个统计信息来确定表是否为空。


推荐阅读