Search code examples
cassandradatastax-java-driver

What happens to pages not retrieved from Cassandra SELECT query?


I have time series data bucketed by day. When I get a query from client to retrieve data for a particular day, I return a page at a time (500). I use Cassandra's pagination to achieve this. But my question is, what happens when client doesn't ask for the next page? How does server know to garbage collect resultset that is not fully iterated over? I am running into an issue where after many such requests, query performance is degrading significantly.


Solution

  • There is no state associated with paging other than what is communicated in the response message itself. The 'paging state' is a small payload that tracks the partition and clustering information about where the starting point of the remaining data is.

    Because of this, you can safely assume that when you stop paging there is no cost or overhead on the server side. In fact, you can hold on to that paging state and reuse it at a future point in time.