How to obtain number of rows in Cassandra table
Yes, you can use COUNT(*)
. Here's the documentation.
A SELECT expression using COUNT(*) returns the number of rows that matched the query. Alternatively, you can use COUNT(1) to get the same result.
Count the number of rows in the users table:
SELECT COUNT(*) FROM users;
You can use copy to avoid cassandra timeout usually happens on count(*)
cqlsh -e "copy keyspace.table_name (first_partition_key_name) to '/dev/null'" | sed -n 5p | sed 's/ .*//'