2

First of all I am new to Cassandra databases and have read the manual. Now i'm building a basic page to insert and select a couple of rows into my new database. The database only contains 1 table, a users table which looks like this:

The table

Next I use the following code to retrieve data from this table:

        Connect();
        Row result = session.Execute("select * from users where last_name ='Jansen'").First();
        Console.WriteLine("{1} {2}", result["first_name"], result["last_name"]);
        cluster.Shutdown();

Whenever i execute the select statement I get the following error:

'Cassandra.InvalidQueryException' occurred in Cassandra.dll

Additional information: 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

But what I understand from the manual is that allow filtering should not apply on this query, so basically why is this happening?

And my more important question, how can I fix this error?

Update: Table schema looks like this, Table users( user_id text PRIMARY KEY, first_name text, last_name text);

2
  • 1
    Can you give us the table schema ?
    – Will
    Apr 21, 2016 at 13:50
  • @Will Yes, updated
    – Proliges
    Apr 21, 2016 at 13:58

1 Answer 1

4

But what I understand from the manual is that allow filtering should not apply on this query, so basically why is this happening?

I am afraid your understanding is wrong. You want to filter on a non primary key column. In Cassandra, you need to add ALLOW FILTERING for this purpose.

Can you try select * from users where last_name ='Jansen' ALLOW FILTERING

But please remember this is equivalent to doing select * from users and filtering the data from the result. So this is a very heavy operation and causes huge performance impact.

1
  • Oh yes, you are right. I missed the point that allow filtering apply's on non primary key fields.
    – Proliges
    Apr 21, 2016 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.