Wide-column stores

The wide-column model on Cassandra: keyspace, table, partition key and clustering columns, one table per query, and how it differs from the column storage of data warehouses.

  • 21 cards
  • 5 topics
  • Free

The outline, topic by topic

Each topic is weighted the way the exam weighs it.

  1. Concepts
  2. Questions
  3. Sort and link
  4. Scenarios
  5. Understand

A few cards from the deck

  • Wide-column store: what is it?

    Show the answer

    A distributed database where rows are spread across machines according to part of their identifier, then stored in sorted order inside each group.

    Reading a whole group of neighbouring rows is very fast, but a query that does not say which group to look in forces every machine to be queried.

  • With this table, in which order are the rows of sensor c7's partition stored?

    ```sql
    CREATE TABLE mesures (
    capteur text,
    instant timestamp,
    valeur double,
    PRIMARY KEY ((capteur), instant)
    );
    `

    • By instant ascending
    • By valeur ascending, from the smallest reading to the largest
    • In insertion order, with no particular sort
    • By capteur, then by valeur
    Show the answer

    By instant ascending

    The clustering column instant sets the sort inside the partition, ascending by default. valeur is not part of the key: no sort applies to it.

  • In Cassandra, a … groups tables and sets their … factor.

    Show the answer

    In Cassandra, a keyspace groups tables and sets their replication factor.

    The replication factor says how many nodes each partition is copied to. A keyspace thus plays a role close to a schema, with replication added.

  • Partition key: what is it?

    Show the answer

    The part of the primary key whose value, passed through a hash function, decides which cluster nodes a row is stored on.

    All rows sharing the same value form a partition, stored together. An efficient query always supplies this value in full.

  • Reads for one sensor time out and its partition weighs 2 GB. The partition key is capteur alone. What is the fix?

    • Add an extra clustering column at the end of the key
    • Raise the keyspace's replication factor
    • Add the day to the partition key: ((capteur, jour), instant)
    • Query with ALLOW FILTERING so the server scans fewer rows
    Show the answer

    Add the day to the partition key: ((capteur, jour), instant)

    As long as the partition key holds no time bound, a sensor's partition grows endlessly and cannot be spread. A day in the key cuts it into bounded pieces. An extra clustering column or more copies does not change its size.