Chipintoza
Chipintoza

Reputation: 295

Understanding INTERLEAVE in Cloud Spanner INDEX (indices)

What is difference between

CREATE INDEX SongsBySingerSongName 
          ON Songs(SingerId, SongName),
          INTERLEAVE IN Singers

and

CREATE INDEX SongsBySingerSongName 
          ON Songs(SingerId, SongName)

Upvotes: 5

Views: 2499

Answers (1)

Dan McGrath
Dan McGrath

Reputation: 42018

Cloud Spanner will interleave the indexes entries in with the data table.

This means the SongsBySingerSongName index entries for each SingerId are colocated together.

From Spanner > Documentation > Data Definition Language :

Like interleaved tables, entries in an interleaved indexes are stored with the corresponding row of the parent table. See database splits for more details.

and

When should you create an interleaved index? If the index key that you want to use for index operations matches the key of a table, you might want to interleave the index in that table if the row in the table should have a data locality relationship with the corresponding indexed rows.

Upvotes: 6

Related Questions