Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drop table or truncate table in Cassandra, which is better

Tags:

cassandra

We have a use case where we need to re-create a table every day with current data in Cassandra. For this should we use drop table or truncate table, which would be efficient? We do not want the data to be backed up etc?

Thanks Ankur

like image 556
Ankur Avatar asked Jan 07 '15 22:01

Ankur


2 Answers

I think for almost all cases Truncate is a safer operation than a drop recreate. There have been several issues with dropping/recreating in the past with ghost data, schema disagreement, ect... Although there have been a number of fixes to try to make drop/recreate more stable, if its an operation you are performing every day Truncate should be much cheaper and more stable.

like image 192
RussS Avatar answered Nov 03 '22 11:11

RussS


Beware!

From datastax documentation: https://docs.datastax.com/en/archived/cql/3.3/cql/cql_reference/cqlTruncate.html

Note: TRUNCATE sends a JMX command to all nodes, telling them to delete SSTables that hold the data from the specified table. If any of these nodes is down or doesn't respond, the command fails and outputs a message like the following: truncate cycling.user_activity; Unable to complete request: one or more nodes were unavailable.

Unfortunately, there is nothing on the documentation saying if DROP behaves differently

like image 24
Russell Avatar answered Nov 03 '22 11:11

Russell