This is the query I used to create the table:
CREATE TABLE test.comments (msguuid timeuuid, page text, userid text, username text, msg text, timestamp int, PRIMARY KEY (msguuid));
I want to get the last 50 rows sorted by timestamp in descending order.
If I try something like: SELECT * FROM test.comments WHERE page = 'test' AND timestamp < 1496468332
, I get this error:
Error from server: code=2200 [Invalid query] message="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"
I'd prefer not to use allow filtering, I want the query to be as quick as possible.
I've looked at another stackoverflow question here Cassandra cql: how to select the LAST n rows from a table and tried the solution:
CREATE TABLE test.comments (msguuid timeuuid, page text, userid text, username text, msg text, timestamp int, PRIMARY KEY (msguuid)) WITH CLUSTERING ORDER BY (msguuid DESC);
But then I get this error: InvalidRequest: Error from server: code=2200 [Invalid query] message="Only clustering key columns can be defined in CLUSTERING ORDER directive"
I'm new to Cassandra, so forgive me if this has an obvious answer. I just can't seem to get it to work.
I would highly appreciate if anyone could help me.