Query results not ordered despite WITH CLUSTERING ORDER BY

后端 未结 2 500
遇见更好的自我
遇见更好的自我 2020-12-20 06:00

I am storing posts from all users in table. I want to retrieve post from all users the user is following.

CREATE TABLE posts (
  userid int,
  time timestamp         


        
2条回答
  •  無奈伤痛
    2020-12-20 06:10

    This is my new schema,

    CREATE TABLE posts(id uuid, 
    userid int,
    follows int,
    created timestamp,
    PRIMARY KEY (userid, follows)) WITH CLUSTERING ORDER BY (created DESC);
    

    Here userid represents who posted it and follows represents userid for his one of the follower. Say user x follows 10 other people , i am making 10+1 inserts. Definitely there is too much data duplication. However now its easier to get timeline for one of the user with following query

    select * from posts where follows=?
    

提交回复
热议问题