【发布时间】:2015-11-29 14:13:47
【问题描述】:
我们已经使用 Cassandra 有一段时间了,我们正在尝试获得一个真正优化的表,该表将能够快速查询和过滤大约 100k 行。
我们的模型看起来像这样:
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
我们怎样才能完成类似的任务?
【问题讨论】:
标签: python django python-2.7 cassandra