這是我用來創建表的查詢:如何使用Cassandra CQL獲取此表的最後50行?
CREATE TABLE test.comments (msguuid timeuuid, page text, userid text, username text, msg text, timestamp int, PRIMARY KEY (msguuid));
我想通過時間戳降序排列的最後50行。
如果我嘗試類似:SELECT * FROM test.comments WHERE page = 'test' AND timestamp < 1496468332
,我得到這個錯誤:
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"
我寧願不使用允許過濾,我希望查詢儘可能快。
我在另一個問題計算器看着這裏Cassandra cql: how to select the LAST n rows from a table,並試圖解決方案:
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);
但後來我得到這個錯誤:InvalidRequest: Error from server: code=2200 [Invalid query] message="Only clustering key columns can be defined in CLUSTERING ORDER directive"
我是新來卡桑德拉,因此,如果這見諒有一個明顯的答案。我似乎無法得到它的工作。
如果有人能幫助我,我將非常感謝。
頁面是否爲索引字段? –
是的,頁面已編入索引 –
您正在使用哪個cassandra版本? –