我们现在一直在使用Cassandra,并且我们试图获得一个真正优化的表,它将能够快速查询和过滤大约100k行。基于二级索引的Cassandra过滤器
我们的模型看起来是这样的:
class FailedCDR(Model):
uuid = columns.UUID(partition_key=True, primary_key=True)
num_attempts = columns.Integer(index=True)
datetime = columns.Integer()
如果我形容它的表清楚地表明,num_attempts
是指数。
CREATE TABLE cdrs.failed_cdrs (
uuid uuid PRIMARY KEY,
datetime int,
num_attempts int
) WITH bloom_filter_fp_chance = 0.01
AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}'
AND comment = ''
AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'}
AND compression = {'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND dclocal_read_repair_chance = 0.1
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = '99.0PERCENTILE';
CREATE INDEX index_failed_cdrs_num_attempts ON cdrs.failed_cdrs (num_attempts);
我们希望能够运行一个类似的过滤器:
failed = FailedCDR.filter(num_attempts__lte=9)
但出现这种情况:
QueryException: Where clauses require either a "=" or "IN" comparison with either a primary key or indexed field
我们如何能完成类似的任务?