4

I want to check if a select query reached the limit. In this case I want to avoid fetching any result and do nothing:

Statement statement = session.prepare("SELECT user_id, payload FROM db.users WHERE user_id = :user_id LIMIT 5000").bind().setUUID("user_id", userId).setFetchSize(100)
ResultSet resultSet = session.execute(statement)
if (resultSet didn't reached the limit of 5000) {
  //do stuff
} else {
  //do nothing
}

I thought getAvailableWithoutFetching will do this trick but it return number of results per page (fetch size).
Is there a way to do this without an extra query just for count?
It should be a rare case and I don't want to create an extra query every time to check the limit. especially when count(*) scan for all results without option to limit - Cassandra CQL Select count with LIMIT

Boaz
  • 1,212
  • 11
  • 25

1 Answers1

0

Is there a way to do this without an extra query just for count?

No. Your "non fetching" query would be just that, a query for the count.