O'Reilly logo

Apache Cassandra Essentials by Nitin Padalia

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required