liveBook · Manning

Global secondary index

As explained in ScyllaDB in Action

A global secondary index is an index whose partitioning differs from that of its base table and whose indexed data can be distributed across different cluster nodes.

A global secondary index lets ScyllaDB query indexed columns without the base table’s partition key. It maintains a mapping from indexed values to rows, but partitions that mapping differently from the base table, so indexed data may live on different cluster nodes. section 7.3.3

Indexing authors by name

For the reviews application, `CREATE INDEX authors_by_name ON authors(name);` creates a global index because `authors` is partitioned by `id`, which is absent from the index. A query such as `SELECT * FROM reviews.authors WHERE name = 'Alice Author';` can then find the matching row without specifying `id`.

The convenience has a cluster-wide cost. A lookup first reads the index and then reads matched rows from the base table; broad searches can fan out across many partitions and add load to every node. A local secondary index avoids this fanout by sharing the base table’s partition key, while a materialized view instead duplicates data under a query-specific partitioning scheme. section 7.3.3 section 7.4

How ScyllaDB in Action covers it

How deep it goes
Explains index mappings, partition placement, two-stage reads, and cluster-wide fanout risks; it stops short of detailed implementation internals.
Examples
Uses an authors-by-name index, an author lookup, and a comparison with an authors index sharing the base partition key.
What it assumes
Assumes familiarity with base tables, rows, primary keys, partition keys, and distributed cluster nodes.
What you can do after
Diagnose whether an indexed query may create two-stage reads and cluster-wide fanout, then compare it with a local index or materialized view.
How it connects
Contrasts global secondary indexes with local secondary indexes, materialized views, partition keys, and ALLOW FILTERING.

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.