Build Cloud-Native apps with Apache Cassandra

GOT QUESTIONS from the Workshop? You're in the right place! Post a question here and we'll get you answers.

Click here for Week 7 Materials and Homework.

Registrations still open!


question

nirjharray avatar image
nirjharray asked ·

Why are the rows of the video_recommendations table not sorted by videoid?

Even though the table definition for killrvideo.video_recommendations is with videoid in ASC order, why the query results for the query "SELECT * FROM killrvideo.video_recommendations where userid=11111111-1111-1111-1111-111111111111;" does not return the results with videoid in ASC order?

CREATE TABLE killrvideo.video_recommendations (    userid uuid,    added_date timestamp,    videoid uuid,    authorid uuid,    name text,    preview_image_location text,    rating float,    PRIMARY KEY (userid, added_date, videoid) ) WITH CLUSTERING ORDER BY (added_date DESC, videoid ASC)
workshopfaq
cassandra-ques.jpg (61.3 KiB)
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

sriniatoradb_165810 avatar image
sriniatoradb_165810 answered ·

Hi,

The result is based on the following WITH CLUSTERING ORDER BY (added_date DESC, videoid ASC).

Clustering order is performed sequentially , first it will perform sorting on added_date in desc order and videoid is in asc order.


Thanks




Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.