Search code examples
pythonpython-3.xcassandracqlcql3

Will auto-pagination work in Cassandra without providing the limit?


After reading doc(driver doc) and few answers, it seems that Cassandra 2.0+ has an auto paging. But all such examples included LIMIT keyword.

Does this query applicable in auto-paging:

current_version_query = "SELECT id, row_hash FROM {} WHERE version={}".format(
            self.table_name, self.diff_source_version
        )
        current_version_rows = self.session.execute(
            current_version_query
        )

I am iterating over it here: for current_version_row in current_version_rows:


Solution

  • There are two limits, a fetch size and a total request limit (LIMIT clause). When you make any request there is a default 5000 fetch limit and max_int query limit.

    The driver will by default page in 5000 row batches until it reaches the query limit or the end of the results. It is often a good idea to lower this if your rows are large to reduce load on the coordinator from building MBs of response payloads.