gpt4 book ai didi

database - 按主键和列的 Cassandra 查询抛出错误

转载 作者:搜寻专家 更新时间:2023-10-30 22:05:43 25 4
gpt4 key购买 nike

架构

CREATE TABLE books (
isbn text PRIMARY KEY,
author text
);

insert into books (isbn, author) values ('111', 'Sally');
insert into books (isbn, author) values ('112', 'Fred');
insert into books (isbn, author) values ('113', 'Joe');

有了上面的数据,我就可以通过主键111进行查询了

select * from books where isbn = '111';

但是,当我将 author 放入 where 条件时它会抛出错误

从 isbn = '111' 和 author = 'Fred' 的书中选择 *;

Query 1 ERROR: Cannot execute this query as it might involve data filtering and thus may have unpredictable performance. If you want to execute this query despite the performance unpredictability, use ALLOW FILTERING

我无法理解,如果数据已经通过主键(只有一条记录)过滤,为什么会抛出错误?

其次,如果我使用allow filtering 是否会影响性能?

编辑:https://dzone.com/articles/apache-cassandra-and-allow-filtering给了我一些线索。

最佳答案

link可能会帮助你。据我了解,如果您 allow filtering (猜测它类似于 SQL RBAR ,它很慢,以及它抛出和过滤错误的原因)

我对 cassandra 还是比较陌生,但是根据我的阅读,如果您还没有定义二级索引,您需要运行选择查询以包含主键中定义的所有列。但二级索引存在局限性。

HTH 祝你好运。

关于database - 按主键和列的 Cassandra 查询抛出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55877084/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com