google cloud spanner - Understanding Secondary Indexes -


if have table table

create table users (     userid string(36) not null,     contactname string(300) not null,     email string(100) not null,     .... ) primary key (userid) 

and secondary index

create null_filtered index activeusersbyemail  on users (     email,     isactive, ) 

and select record by:

select * users email = 'test@test.com' , isactive = true 

spanner automatically @ index, take userid , give me record ?.

or need create

create null_filtered index activeusersbyemail_01  on users (     email,     isactive,     userid ) 

and first take userid by:

select userid users@{force_index=activeusersbyemail_01} email = 'test@test.com' , isactive = true 

and take record by:

`select * users userid = '${userid}'`` 

question automatically use or not spanner secondary indices standard select if condition match secondary index keys?

you should use force_index cloud spanner choose index in rare circumstances stated here. can use storing clause add data directly index, allowing read data directly index avoid second call. suggested common query patterns in application.


Comments