简体   繁体   中英

Cassandra pagination inside partition

How can I paginate data inside partition? I can`t use token for this, so I made microtime field with creation time and ordered records by it. Now I am slicing data using '<' and '>' and it makes a lot of constraints for my queries. Is there better way to do this?

For forward pagination, most of drivers (I definitely know about Java & Node.js) have notion of paging . You're basically execute your query, but set fetch size to value of number of entries that you want to have on page. You can grab current "paging state" and set it into cookier, or hidden form parameter of the page, and restore it when user clicks on "next" button, so you can retrieve next page.

Backward paging is more tricky, but is also doable - basically, you need to store somewhere the value of the clustering key(s) for first record that you output on previous page, and then execute query like select * from table where partition_key = value and clustering_column > value .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM