Database / ScyllaDB Interview questions
Define a partition key in ScyllaDB?
A partition key is the portion of a table's primary key that determines which node(s) store a given row, by hashing the key value into a token that maps to a range owned by a specific replica set. Every row with the same partition key lands in the same partition, physically together on disk.
CREATE TABLE sensor_readings ( sensor_id text, reading_time timestamp, value double, PRIMARY KEY (sensor_id, reading_time) );
Here sensor_id is the partition key: all readings for one sensor are stored together and can be read efficiently as a range. Choosing a partition key with high cardinality and even access patterns is critical, since a key with too few distinct values, or one that concentrates traffic, creates an oversized or overloaded partition that a single set of replicas must absorb.
More Related questions...