Allowing filtering

Cassandra, by default, only allows those queries which don't require any server-side filtering. Cassandra does this to avoid performance hits that might be caused due to these queries. Let's take the example of the employee table, which stores employee salary details department-wise:

CREATE TABLE employee ( emp_id text PRIMARY KEY, first_name text, last_name text, department text,  salary int )
CREATE INDEX emp_salary ON employee(salary)
CREATE INDEX emp_department ON employee(department)

Now, if you want to get the details of all the employees in the sales department with a salary of more than 100000, you might want to run a query as follows:

SELECT first_name, last_nameFROM employee WHERE department = 'sales' AND salary > 100000 ...

Get Apache Cassandra Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.