question

haripriyan.mr_191315 avatar image
haripriyan.mr_191315 asked Erick Ramirez answered

Can we retrieve the oldest videos first for a table with PRIMARY KEY ((tag), video_id, added_date))?

[FOLLOW UP QUESTION TO #9296]

CREATE TABLE videos_by_tag (
    tag text,
    video_id timeuuid,
    added_date timestamp,
    title text,
    PRIMARY KEY ((tag), video_id, added_date)
) WITH CLUSTERING ORDER BY (video_id ASC, added_date DESC);

Execute your query again, but list the oldest videos first? Is there a possibility to achieve this without modifying the DDL with CLUSTERING ORDER BY (added_date ASC, video_id)?

data modeling
10 |1000

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

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered

Unless you have indexes (like native secondary indexes), it isn't possible to query the data in that manner.

In Cassandra, one of the primary principles of Data Modelling is to design one table for each application query for optimum performance. The difference compared to relational databases is that you have a scale problem so you choose Cassandra to achieve high availability and high throughput. As such, you need to model your data for maximum performance. Cheers!

Share
10 |1000

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