我使用Python卡桑德拉Cqlengine扩展。 我创造了许多对多表,但我收到错误user_applications模型查询过滤过程。 我readed不同的资源对于这个问题,但我没有完全理解这个问题。
来源: https://ohioedge.com/2017/07/05/cassandra-primary-key-partitioning-key-clustering-key-a-simple-explanation/
卡桑德拉允许过滤
被允许卡桑德拉滤波下面的查询效率?
数据库模型:
class UserApplications(BaseModel):
__table_name__ = "user_applications"
user_id = columns.UUID(required=True, primary_key=True, index=True)
application_id = columns.UUID(required=True, primary_key=True, index=True)
membership_id = columns.UUID(required=True, primary_key=True, index=True)
错误信息:
无法执行此查询,因为可能涉及数据过滤,因此可能具有不可预知的性能。 如果你想,尽管性能不可预测性来执行这个查询,使用允许过滤的”
Python的CQLEngine代码:
q = UserApplications.filter(membership_id=r.membership_id,
user_id=r.user_id,
application_id=r.application_id)
CQLEngine SQL语句:
SELECT "id", "status", "created_date", "update_date" FROM db.user_applications WHERE "membership_id" = %(0)s AND "user_id" = %(1)s AND "application_id" = %(2)s LIMIT 10000
说明表结果:
CREATE TABLE db.user_applications (
id uuid,
user_id uuid,
application_id uuid,
membership_id uuid,
created_date timestamp,
status int,
update_date timestamp,
PRIMARY KEY (id, user_id, application_id, membership_id)
) WITH CLUSTERING ORDER BY (user_id ASC, application_id ASC, membership_id ASC)
AND 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', 'max_threshold': '32', 'min_threshold': '4'}
AND compression = {'chunk_length_in_kb': '64', 'class': '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 = 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 = '99PERCENTILE';
CREATE INDEX user_applications_membership_id_idx ON db.user_applications (membership_id);
等待您的帮助。