SELECT (CQL)

Queries rows from a table. Cassandra requires queries to filter by the partition key. Range queries on clustering columns are efficient. ALLOW FILTERING forces a full scan (avoid in production).

Syntax

cassandra
SELECT cols FROM table WHERE partition_key = val [AND clustering_col op val] [LIMIT n];

Example

cassandra
SELECT * FROM user_events
WHERE user_id = 123e4567-e89b-12d3-a456-426614174000
LIMIT 20;

SELECT * FROM user_events
WHERE user_id = ? AND event_time > ? AND event_time < ?;