我有一张锡拉表,如下所示:
cqlsh:sampleks> describe table test;
CREATE TABLE test (
client_id int,
when timestamp,
process_ids list<int>,
md text,
PRIMARY KEY (client_id, when) ) WITH CLUSTERING ORDER BY (when DESC)
AND bloom_filter_fp_chance = 0.01
AND caching = {'keys': 'ALL', 'rows_per_partition': 'ALL'}
AND comment = ''
AND compaction = {'class': 'TimeWindowCompactionStrategy', 'compaction_window_size': '1', 'compaction_window_unit': 'DAYS'}
AND compression = {'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND crc_check_chance = 1.0
AND dclocal_read_repair_chance = 0.1
AND default_time_to_live = 0
AND gc_grace_seconds = 172800
AND max_index_interval = 1024
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = '99.0PERCENTILE';
我看我们就是这样质疑的。我花了很长时间研究Cassandra所以这个 PER PARTITION LIMIT
对我来说是新事物(看起来像是最近添加的)。有人能用外行的语言解释一下这个例子是怎么回事吗?我找不到一个好医生来解释这个问题。
SELECT * FROM test WHERE client_id IN ? PER PARTITION LIMIT 1;
1条答案
按热度按时间vyu0f0g11#
这个
PER PARTITION LIMIT
子句在“宽分区场景”中很有用,它只返回分区中的前两行。接受此查询:
考虑到
(client_id,when)
,该查询将在每个client_id
. 然后cassandra将只返回前两行(按when
)不管有多少人when
可能存在。在本例中,我在
test
表,使用两个不同的client_id
s(共2个分区)。使用PER PARTITION LIMIT
在2行中,返回4行(2client_id
十PER PARTITION LIMIT
2) ==4行。