Check which tables are empty in Cassandra

Viewed 93

I need to check which tables are empty in Cassandra over a few keyspaces and there are over 20 tables. I could do a count on every single table but that's a little troublesome...

Is there a way to see the counts for every single table across the different keyspaces without typing all the 20+ queries? I have the tables in a comma-delimited list if that helps.

Edit: I used python to help with this but am interested in a Cassandra solution.

1 Answers

You could also try it at the command line level with 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

Granted, this is only reflective of the node that the command is on. But you should be able to ascertain whether or not a table is empty by this or several of the other statistics available in the tablestats output.

Related