【问题标题】:Check which tables are empty in Cassandra检查 Cassandra 中哪些表是空的
【发布时间】:2021-06-15 21:09:23
【问题描述】:

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

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

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

【问题讨论】:

    标签: cassandra


    【解决方案1】:

    您也可以在命令行级别使用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 输出中提供的这个或其他几个统计信息来确定表是否为空。

    【讨论】:

      猜你喜欢
      • 2021-08-16
      • 1970-01-01
      • 1970-01-01
      • 2019-04-25
      • 1970-01-01
      • 2015-06-30
      • 2018-12-13
      • 2015-01-21
      • 2022-01-15
      相关资源
      最近更新 更多