Reputation: 299
We are using Cassandra
cqlsh 5.0.1 | Cassandra 2.1.14.1272 | DSE 4.8.7 | CQL spec 3.2.1
We have around > 600000 rows where we have inserted NULLs in most of the cells for this row. We run a query which scans through 8000 rows with dates of yesterday, today,tomorrow. However when I enabled tracing I find only :
Read 101 live and 997 tombstone cells [SharedPool-Worker-1] | 2017-04-20 11:05:02.901000 | 10.74.70.30 | 11297
I know that inserting NULLs in Cassandra create tombstones for those cells but why can I only see such few tombstones even though the query is returning 8k records with each record holding multiple NULLs? Can anything explain this? The TTL for these records is 30 days by default and so this result set of 8k cannot have tombstones because of TTL.
EDIT 1
My schema is :
CREATE TABLE transportation_events.events_for_load_ops_exceptions (
exception_phase text,
exception_date text,
event_id timeuuid,
actual_delivery_ts timestamp,
actual_pickup_ts timestamp,
carrier_due_ts timestamp,
carrier_id text,
carrier_mode text,
carrier_pickup_ts timestamp,
dest_loc_banner_code text,
dest_loc_class_code int,
dest_loc_id int,
dest_loc_name text,
dest_loc_type text,
dest_time_zone text,
destination_city text,
destination_postal_code text,
destination_state text,
destination_street_addr text,
exception_type text,
late_reason_code text,
load_id text,
load_type text,
loc_time_zone text,
orig_loc_id int,
orig_loc_name text,
orig_loc_type text,
orig_time_zone text,
origin_city text,
origin_postal_code text,
origin_state text,
origin_street_addr text,
reason_code_category text,
reason_code_desc text,
scheduled_delivery_ts timestamp,
scheduled_pickup_ts timestamp,
status_reason_code text,
stop_loc_id int,
stop_loc_name text,
stop_loc_type text,
stop_seq_num int,
stop_type text,
triggered_by text,
PRIMARY KEY ((exception_phase, exception_date), event_id)
) WITH CLUSTERING ORDER BY (event_id DESC)
And am saving to Cassandra by
import com.datastax.driver.mapping.Mapper;
mapper.save(resultRecord);
I can see through CQL that is has inserted NULLs .
Query I am tracing
select * from transportation_events.events_for_load_ops_exceptions where exception_phase='PLANNING' AND exception_date IN ('2017-04-19','2017-04-20','2017-04-21');
Perhaps the compaction has removed most of the tombstones? Is there any other explanation? EDIT 2 If there is a way to summarize and see the tombstones and their causes at once common place for the query? Like a tombstone dump for a table?
Upvotes: 2
Views: 705
Reputation: 2466
You can insert NULL as a value, so it will not create a tombstone.
Depending on the driver you are using, review the differences between inserting null and nulls as a value.
Another option, you can have one tombstone for hall row, or even partition, instead of one tombstone for each value.
Upvotes: 2