I have two questions about query results in Cassandra.
When I make a “full” table selection in Cassandra (i.e. select * from table ), is it guaranteed that the results will be returned in ascending order of split tokens? For example, having the following table:
create table users(id int, name text, primary key(id));
Is it guaranteed that the next query will return results with increasing values in the token column?
select token(id), id from users;
If so, is the distribution of data across multiple nodes in the cluster also guaranteed?
If the underwriter on the above question is yes, is it still valid if we use a secondary index? For example, if we had the following index:
create index on users(name);
and we query the table using the index:
select token(id), id from users where name = 'xyz';
Is there any guarantee regarding the order of the results?
The motivation for the above questions is that a token is the right thing to use in order to implement paging and / or resume a longer “data export”.
EDIT: There are several resources on the network that claim that the order corresponds to the order of the marker (for example, in the description of the separator results or this Datastax page ):
Without the section key specified in the WHERE clause, the actual result set order becomes dependent on the hashed userid values.
However, the order of the results is not indicated in the official Cassandra documentation, for example. SELECT statement .
source share