1

I have to jump to specific rows in AWS Keyspaces table. In specific I am doing pagination so I want to be able to jump to a specific page. Do I have any options for that?

For example, I have to fetch 100 rows after 1e+6 row. And ofc I want to do it as quickly as possible.

My ideas/solutions:

  1. Set page size to requested one (100 in this case) and iterate over all rows and get next_page until come up with a specific set
  2. Find max possible size of the page and use max_page to iterate over the biggest possible sets of rows

But maybe there are more clever solutions?

I don't have the opportunity to somehow change the table by adding additional columns!

Ilya
  • 45
  • 1
  • 10

1 Answers1

3

Pagination isn't a best practice in Cassandra because you don't know how many results you will have until you query for them. Amazon Keyspaces paginates results based on the number of rows that it reads to process a request, not the number of rows returned in the result set. As a result, some pages might contain fewer rows than you specify in PAGE SIZE for filtered queries. In addition, Amazon Keyspaces paginates results automatically after reading 1 MB of data to provide customers with consistent, single-digit millisecond read performance.

For Paginating through pages we have a tool called the Export tool. This tool allows you to asynchronously read page by page. It will read partition keys even if you skip them. In Keyspaces still has to read every partition key which means using more RCUs, but this will accomplish your goal. When you are using the tool to read by page you may see the tool stop after a certain number of pages, you just restart the tool at the page it left off at when you run it again.

Autumn88
  • 351
  • 1
  • 11