Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get tombstone count for a cql query?

I am trying to evaluate number of tombstones getting created in one of tables in our application. For that I am trying to use nodetool cfstats. Here is how I am doing it:

create table demo.test(a int, b int, c int, primary key (a));
insert into demo.test(a, b, c) values(1,2,3);

Now I am making the same insert as above. So I expect 3 tombstones to be created. But on running cfstats for this columnfamily, I still see that there are no tombstones created.

nodetool cfstats demo.test
Average live cells per slice (last five minutes): 0.0
Average tombstones per slice (last five minutes): 0.0

Now I tried deleting the record, but still I don't see any tombstones getting created. Is there any thing that I am missing here? Please suggest.

BTW a few other details, * We are using version 2.1.1 of the Java driver * We are running against Cassandra 2.1.0

like image 297
Prasanth Avatar asked Nov 21 '14 14:11

Prasanth


People also ask

How do you know how many tombstones you have in Cassandra?

Guys, just run some "nodetool cfstats keyspace | tee tombstone. txt", analyze the content and identify the tables with tombstones. Enable tracing, run a query like RussS` and you`ll notice in the tracing output how the read process occurs, how many tombstones are actually parsed to fulfill a query.

What are tombstones in Cassandra?

In Cassandra, deleted data is not immediately purged from the disk. Instead, Cassandra writes a special value, known as a tombstone, to indicate that data has been deleted. Tombstones prevent deleted data from being returned during reads, and will eventually allow the data to be dropped via compaction.

What are tombstone cells?

Cell tombstones are generated when explicitly deleting a value from a cell, such as a column for a specific row of a partition, or when inserting or updating a cell with null values, as shown in the following example.


1 Answers

For tombstone counts on a query your best bet is to enable tracing. This will give you the in depth history of a query including how many tombstones had to be read to complete it. This won't give you the total tombstone count, but is most likely more relevant for performance tuning.

In cqlsh you can enable this with

cqlsh> tracing on;
Now tracing requests.
cqlsh> SELECT * FROM ascii_ks.ascii_cs  where pkey = 'One';

 pkey | ckey1 | data1
------+-------+-------
  One |   One |   One

(1 rows)


Tracing session: 2569d580-719b-11e4-9dd6-557d7f833b69

 activity                                                                 | timestamp    | source    | source_elapsed
--------------------------------------------------------------------------+--------------+-----------+----------------
                                                       execute_cql3_query | 08:26:28,953 | 127.0.0.1 |              0
 Parsing SELECT * FROM ascii_ks.ascii_cs  where pkey = 'One' LIMIT 10000; | 08:26:28,956 | 127.0.0.1 |           2635
                                                      Preparing statement | 08:26:28,960 | 127.0.0.1 |           6951
                             Executing single-partition query on ascii_cs | 08:26:28,962 | 127.0.0.1 |           9097
                                             Acquiring sstable references | 08:26:28,963 | 127.0.0.1 |          10576
                                                Merging memtable contents | 08:26:28,963 | 127.0.0.1 |          10618
                                              Merging data from sstable 1 | 08:26:28,965 | 127.0.0.1 |          12146
                                              Key cache hit for sstable 1 | 08:26:28,965 | 127.0.0.1 |          12257
                                                    Collating all results | 08:26:28,965 | 127.0.0.1 |          12402
                                                         Request complete | 08:26:28,965 | 127.0.0.1 |          12638

http://www.datastax.com/dev/blog/tracing-in-cassandra-1-2

like image 118
RussS Avatar answered Nov 24 '22 07:11

RussS