运行查询时为什么会遇到此错误?

发布于 2025-01-25 10:33:43 字数 1219 浏览 3 评论 0原文

尝试执行此查询时:

select race_name from sport_app.month_category_runner where race_type = 'URBAN RACE 10K' and club = 'CORNELLA ATLETIC';

我会收到以下错误:

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

这是一个练习,因此我不允许使用允许过滤。

因此,我以这种方式创建了两个索引:

create index raceTypeIndex ON sport_app.month_category_runner(race_type);
create index clubIndex ON sport_app.month_category_runner(club);

但是我一直遇到相同的错误,我是否缺少某些东西,还是有其他替代方案?

表结构:

CREATE TABLE month_category_runner (month text,

                            category text,

                            runner_id text,

                            club text,

                            race_name text,

                            race_type text,

                            race_date timestamp,

                            total_runners int,

                            net_time time,

                            PRIMARY KEY (month, category, runner_id, race_name, net_time));

When attempting to perform this query:

select race_name from sport_app.month_category_runner where race_type = 'URBAN RACE 10K' and club = 'CORNELLA ATLETIC';

I get the following 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

It is an exercise, so I am not allowed to use ALLOW FILTERING.

So I have created two indexes in this way:

create index raceTypeIndex ON sport_app.month_category_runner(race_type);
create index clubIndex ON sport_app.month_category_runner(club);

But I keep getting the same error, am I missing something, or is there an alternative?

Table Structure:

CREATE TABLE month_category_runner (month text,

                            category text,

                            runner_id text,

                            club text,

                            race_name text,

                            race_type text,

                            race_date timestamp,

                            total_runners int,

                            net_time time,

                            PRIMARY KEY (month, category, runner_id, race_name, net_time));

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

面如桃花 2025-02-01 10:33:44

请注意,如果添加“允许过滤”,查询将在Cassandra群集的所有节点上运行,并且可能对所有节点产生很大的影响。

建议是将分区添加为查询条件,以允许仅在所需的节点上执行查询。

示例:

从月_category_runner中选择race_name,其中一个月='may'and club ='cornella atletic';

从月_category_runner中选择race_name,其中一个月='五月'和race_type ='Urban Race 10k';

从noter_category_runner中选择race_name where ='五月'和race_type ='Urban Race 10k'和club ='Cornella Atletic'允许过滤;

您的主键由(一个月,类别,runner_id,race_name,net_time)组成,并且列月是分区,因此该列必须在您的查询过滤器上,如我所示。

尽管存在索引列,但要使用两个不在主键中的两个列进行查询,您需要使用可能具有性能影响的允许过滤;

另一个选项是创建一个新表,其中主键包含这些列。

Note if you add the "ALLOW FILTERING" the query will run on all the nodes of Cassandra cluster and can have a large impact on all nodes.

The recommendation is to add the partition as condition of your query, to allow the query to be executed on needed nodes only.

Example:

select race_name from month_category_runner where month = 'may' and club = 'CORNELLA ATLETIC';

select race_name from month_category_runner where month = 'may' and race_type = 'URBAN RACE 10K';

select race_name from month_category_runner where month = 'may' and race_type = 'URBAN RACE 10K' and club = 'CORNELLA ATLETIC' ALLOW FILTERING;

Your primary key is composed by (month, category, runner_id, race_name, net_time) and the column month is the partition, so this column must be on your query filter as i showed in example.

The query that you want to do using two columns that are not in primary key despite the index column exist, you need to use the ALLOW FILTERING that can have performance impact;

The other option is create a new table where the primary key contains theses columns.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文