5

What is difference between

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

and

CREATE INDEX SongsBySingerSongName 
          ON Songs(SingerId, SongName)
Drew
  • 6,311
  • 4
  • 44
  • 44
Chipintoza
  • 295
  • 4
  • 16

1 Answers1

5

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.

Drew
  • 6,311
  • 4
  • 44
  • 44
Dan McGrath
  • 41,220
  • 11
  • 99
  • 130