liveBook · Manning

Token range

As explained in ScyllaDB in Action

A token range is an interval of the token space whose partitions are assigned to one or more nodes in a distributed database cluster.

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.
figure

Contrasts inefficient partition-key slicing with TOKEN-based queries narrowed to a single token range. section 12.1.1

How ScyllaDB in Action covers it

How deep it goes
Explains hashing, ownership, replication, vnode boundaries, and operations, without developing token-hashing internals.
Examples
Uses CQL TOKEN predicates, nodetool describering output, node replacement, and token-range repair examples.
What it assumes
Assumes partition keys, hashing, replication, and hash rings, while connecting them to practical ScyllaDB operations.
What you can do after
Apply it via CQL TOKEN queries and ScyllaDB operational tools to target, replace, or repair distributed data ranges.
How it connects
Connects token ranges with partition keys, hashing, hash rings, replication, virtual nodes, CQL TOKEN, and Scylla Manager.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ScyllaDB in Action. The section links point to the parts of the book it draws on.