A token range is an interval in the token space owned by a node and replicated to succeeding nodes in the hash ring. Because partition keys are hashed into tokens, token ranges—not nearby key values—identify where data resides. section 12.1.1
Token ranges support both efficient data movement and cluster operations:
- Query ranges with ScyllaDB’s TOKEN function instead of subdividing partition-key values, which can involve many or all nodes. section 12.1.1
- Use vnode boundaries as slice boundaries, discovering ownership with nodetool describering and driver metadata. section 12.1.1
- Replace a failed or changed node by assigning its previous token ranges to the new node. section 9.4.2
- Repair replicas across token ranges, either directly with nodetool repair or through Scylla Manager’s scheduled orchestration. section 9.3.1
Querying one token range
A bulk export can restrict a query to one interval: SELECT * FROM articles WHERE TOKEN(id) >= ... AND TOKEN(id) < ...; Choose boundaries from vnode ranges so the query targets only the necessary node and replicas. section 12.1.1
Figure 12.1 Attempting to export data via performing range queries using the partition key is an inefficient pattern that adds unnecessary load to your cluster, but you can use the TOKEN function to narrow these large queries to a single token range.
Contrasts inefficient partition-key slicing with TOKEN-based queries narrowed to a single token range. section 12.1.1
