A drop of a table or a truncation table in Kassandra which is better

We have a precedent when we need to create a table with the current data in Cassandra every day. To do this, use the drop table or truncate, which will be effective? We do not want the data to be copied, etc.?

Thanks Ankur

+9
source share
4 answers

I think that in almost all cases, Truncate is a safer operation than reconstituting a drop. In the past, there have been several problems with dropping / re-creating with ghost data, schema inconsistencies, etc. Although there have been many fixes to try to make recovery / recovery more stable, if this is an operation that you perform every day, truncation should be much cheaper and more stable.

+7
source

In the Drop table, the table and all the data drop out. Truncate clears all the data in the table and, by default, creates a snapshot of the data (but not the schema). Efficiency is wise, they are close, although truncate will create a snapshot. You can disable this by setting auto_snapshot to false in the cassandra yaml setting, but it is a server server. If this is not so difficult, I would reset and re-earn the table, but I saw problems if you do not wait for the time after the drop before re-creating.

+7
source

Source: https://support.datastax.com/hc/en-us/articles/204226339-FAQ-How-to-drop-and-recreate-a-table-in-Cassandra-versions-older-than-2- 1

NOTE. By default, snapshots are created when tables are dropped or truncated. This will need to be cleaned manually to free up disk space.

It is also tested manually.

Truncate will save the circuit, but drop will not.

+3
source

Caution!

From the dasastax 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 the SSTable tables containing data from the specified table. If any of these nodes does not work or does not respond, the command fails and displays a message similar to the following: truncate cycling.user_activity; Unable to complete the request: one or more nodes were unavailable.

Unfortunately, the documentation says nothing about DROP behaving differently.

0
source

Source: https://habr.com/ru/post/980678/


All Articles