2
votes

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);

1
Can you give us the table schema ? - Will
@Will Yes, updated - Proliges

1 Answers

4
votes

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.