Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

praveenkg avatar image
praveenkg asked Erick Ramirez edited

Does TRUNCATE create tombstones?

If we truncate table will it create tombstone? also if we delete all the records of a partition key having thousands of records will create more tombstone?

tombstones
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

steve.lacerda avatar image
steve.lacerda answered

Hi! Truncate will not create tombstones, it'll remove all of the data instead of marking the data as deleted. In regards to the partition level tombstones, if you delete by the partition key then it will mark the partition as deleted and remove all of the rows below the partition, so no, you will not have any tombstones except the one partition level tombstone, which is not an issue.

For example, here's our table definition:

CREATE TABLE cycling.route (race_id int, race_name text, point_id int, lat_long tuple<text, tuple<float,float>>, PRIMARY KEY (race_id, point_id));

The partition delete would look like the following where race_id is the partition key from above:

DELETE FROM cycling.calendar WHERE race_id = 200; 

You would get 1 tombstone for the partition level delete, but that's it.

What you wouldn't want to do is go in and delete each row within the partition, that would create a lot of tombstones and that's what you want to avoid.

Partition level tombstones are fine, TTL's aren't as bad as normal tombstones either, but column and row level tombstones are what you want to stay away from.

Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.