我们正在使用 Cassandra
cqlsh 5.0.1 | Cassandra 2.1.14.1272 | DSE 4.8.7 | CQL spec 3.2.1
我们有大约 > 600000 行,我们在该行的大多数单元格中插入了 NULL。我们运行一个查询,它扫描 8000 行,日期为昨天、今天、明天。但是,当我启用跟踪时,我发现只有:
Read 101 live and 997 tombstone cells [SharedPool-Worker-1] | 2017-04-20 11:05:02.901000 | 10.74.70.30 | 11297
我知道在 Cassandra 中插入 NULL 会为这些单元格创建墓碑,但为什么即使查询返回 8k 条记录且每条记录都包含多个 NULL,我也只能看到这么少的墓碑?有什么可以解释的吗?这些记录的 TTL 默认为 30 天,因此这个 8k 的结果集由于 TTL 而不能有墓碑。
编辑 1
我的架构是:
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)
我通过以下方式保存到 Cassandra
import com.datastax.driver.mapping.Mapper;
mapper.save(resultRecord);
我可以通过已插入 NULLs 的 CQL 看到。
查询我正在追踪
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');
也许压实已经移除了大部分墓碑?还有其他解释吗? 编辑 2 如果有一种方法可以汇总并立即查看墓碑及其原因,以便进行查询?就像一张桌子的墓碑转储?