The TOKEN function computes the hashed token for a partition-key value and shows where that value lies on ScyllaDB’s hash ring. That position helps connect a row to the node or token range responsible for it. section 8.2.1
Use the function to:
- Inspect a key’s token with a query such as SELECT TOKEN(id), id FROM reviews.authors; section 8.2.1
- Restrict bulk reads to token ranges instead of subdividing the ordinary partition-key space, which can involve many or all nodes. section 12.1.1
- Combine TOKEN predicates with vnode boundaries so each extraction query targets only the necessary node and its replicas. section 12.1.1
Reading one token range
A range query can use conditions such as SELECT * FROM articles WHERE TOKEN(id) >= ... AND TOKEN(id) < ...;. Obtain the range boundaries with nodetool describering reviews, whose output includes start tokens, end tokens, and owning endpoints. 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.
Compare inefficient partition-key range queries with TOKEN-based ranges that narrow each operation to a ring slice. section 12.1.1
