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

Sun_P avatar image
Sun_P asked ·

Does multiple INSERT with same primary key create a tombstone?

If we add multiple statement with same primary key as below (col1 and col2 are primary key):-

insert into table (col1,col2,col3) values ('AAA','BBB', {10,20})

insert into table (col1,col2,col3) values ('AAA','BBB', {10,30})

Here, first entry will become tombstone?

When I tried these two statements and after nodetool flush, I used sstabledump utility to check what it shows, but in that no mention of the first statement. What and how exactly this operation gets performed?

When I checked with tracing on, it was showing 0 tombstone scans and I was confused at below line:-

Skipped 3/7 non-slice-intersecting sstables.

what it does indicate?

Thanks.

tombstones
10 |1000 characters needed characters left characters exceeded

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

1 Answer

stefano.lottini avatar image
stefano.lottini answered ·

Hello,

when writing multiple times the same row (= same primary key), no tombstones are generated: tombstones mainly result from explicit DELETE statements

(I stress "mainly", since for example if you write to non-frozen collection-type columns you may trigger creation of tombstones, but I think that's not the point of your question).

If you saw no trace of the first insert, that probably means that the row inserted first was still in the memtable, so the second write managed to replace it in memory. Conversely, if the memtable were flushed between the two inserts, you would have both rows stored (eventually they may end up in different SSTables) and at reading time a timestamp comparation would have been made in order to return you the current value.

As for the message you see, this comes from the read operation and tells you that, in order to fetch and give you the rows you queried for, only three of a total of seven SSTables were inspected since the other four, without even looking into them (i.e. based on their indexes only), were guaranteed not to contain rows relevant to the WHERE clause of your query.

1 comment Share
10 |1000 characters needed characters left characters exceeded

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

Thanks for the detailed answer.

0 Likes 0 ·