Datastax Cassandra auto-limiting response size to 20 when sorting
Author: César Rodriguez
Originally Sourced from: https://stackoverflow.com/questions/79855039/datastax-cassandra-auto-limiting-response-size-to-20-when-sorting
I'm using Cassandra hosted with a free plan in Datastax Astra (in AWS, but I don't think this is relevant) in my project, consuming it with astra-db-ts library.
I'm able to make the migrations normally. Using the same library I was able to programatically create the table countries and seed the data. If I go to the CQL console and run a SELECT * FROM my_keyspace.countries, I get the whole 243 rows as expected.
However, when I run:
await this._db
.table<CountriesAlphabeticalTableSchema, CountriesAlphabeticalTablePrimaryKey>(
ASTRA_TABLES.countriesByAlphabetical, { keyspace: ASTRA_KEYSPACES.countries }
)
.find({}, { sort: { country_code: 1 } })
.map(i => ({ countryCode: i.country_code, possessionOf: i.possession_of }))
.toArray();
I get only the 20 first entries. If I put, let's say, limit: 400 it has no effect.
If I remove the sort, it retrieves all 243 entries, but I want to retrieve the sorted data to avoiding doing it in my application memory. country_code is the primary key.
In this case, sorting in memory won't be a problem, but in some other query it could be. Can someone help me on retrieving all my data and sorting in the query itself?