Cassandra asks for ALLOW FILTERING, even if the column is a clustering key

A very new apology for Cassandra if the question is simple.

I created a table:

create table ApiLog ( LogId uuid, DateCreated timestamp, ClientIpAddress varchar, primary key (LogId, DateCreated)); 

This work is wonderful:

 select * from apilog 

If I try to add a where clause with DateCreated as follows:

 select * from apilog where datecreated <= '2016-07-14' 

I get this:

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

From the other questions cited here in SO, and from the datastax tutorials, I understand that since the dataset column is a clustering key, it can be used to filter data.

I also tried to create an index, but I got the same message. And I tried to remove the DateCreated from the primary key and use it only as an index, and I still get the same answer:

 create index ApiLog_DateCreated on dotnetdemo.apilog (datecreated); 
+5
source share
2 answers

The LogId section key determines which node each section will be stored on. Therefore, if you do not specify a partition key, Cassandra must filter out all the partitions of this table on all nodes to find the corresponding data. That is why you should say LET FILTER, as this operation is very inefficient and discouraged.

If you specify a specific LogId, then Cassandra can find the partition on one node and efficiently query the range using the clustering key.

So, you need to plan your schema so that you can execute your range queries in one section and do not have to perform a full table scan as you are trying to do.

+6
source

The “ALLOW FILTRATION” sentence does not mean that it should be done blindly. It is always better to return to the data model.

So the options are:

  • Data Remodeling and DDL Revision
  • Allow Filtering

Basically, it could be like changing or updating a primary key to support requests.

http://www.devdummy.com/2017/11/resolved-cannot-execute-this-query-as.html

0
source

All Articles