【发布时间】:2017-09-17 00:11:45
【问题描述】:
我们正在使用 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)
我正在通过
保存到 Cassandraimport com.datastax.driver.mapping.Mapper;
mapper.save(resultRecord);
我可以通过插入 NULL 的 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 是否有一种方法可以立即汇总并查看墓碑及其原因,以便查询?就像一张桌子的墓碑转储?
【问题讨论】:
-
你的表的架构是什么?
-
你到底是如何插入 NULL 值的?据我所知,NULL 只会在使用准备好的语句时导致墓碑,因为 Cassandra 无法区分“未设置”参数和 NULL 参数。 C* 版本 NULL as unset。
-
使用 dse API 中的 mapper.save 自动插入 NULL。当我使用 CQLSH 查询行时,我可以看到 NULL。
-
我正在使用 Java 并通过 POJO
-
@DineMartine 更新