Cassandra Technologies

Get Cassandra table count using COPY command :

You can use COPY command to avoid Cassandra timeout that usually happens on count(*) :

Syntax :
cqlsh -e "copy keyspace.table_name (first_partition_key_name) to '/dev/null'" | sed -n 5p | sed 's/ .*//'

Example :

cqlsh 172.11.11.111 -u cassandra -e "copy dse.audit_log (date) to '/dev/null'"

Output :
stdin:1:Exported 96 ranges out of 97 total ranges, some records might be missing
Processed: 149217135 rows; Rate: 8108 rows/s; Avg. rate: 103274 rows/s
149217135 rows exported to 1 files in 24 minutes and 4.911 seconds.


COPY FROM and COPY TO are cqlsh commands for importing and exporting data to/from Cassandra using csv files. 
Here is a brief description on how to use COPY commands in cqlsh.


Comments Rating 0 (0 reviews)

About the author

BestTechReads

Add Comment

Click here to post a comment

Sending

Categories

Categories