July 2018
Intermediate to advanced
506 pages
16h 2m
English
When performing queries over columns other than the primary key column, Cloud Spanner must perform full table scans. In order to avoid this, users may define one or more secondary indexes. A secondary index is defined with a table and one or more columns to be indexed. For example, if we expect that our library books will often be queried by genre, we could create a secondary index for that column by executing the following statement as a Create Table DDL:
CREATE INDEX BooksByGenre ON AuthorBook(genre)
The process of indexing tables can take quite a long time for larger datasets. Once created, Cloud Spanner should intelligently use this index to optimize queries. For example, if we wanted to count the ...