amazon web services - Is this the right approach to index creation in DynamoDB? -


i want create app has list of clients ids (emails in case), phone number , other important information. of time clients table searched using client id (their email) want able search using phone number. want app have text field can either type email or phone number , able retrieve client data.

client ( id, phonenumber, name, lastname, etc...) 

after researching on dynamodb, came solution of having table clients , having index hash key ids lot of throughput read , write since querying based on attribute common task. then, created global secondary index, key attribute phonenumber, , giving low throughput number reading , writing since search of client phone number won't occasional. however, app never make update using phone number key, make updates using id key.

is right approach, or there better thing do? throughput values right based on needs or think there no need have write throughput values secondary index? there maybe wrong thought process?

thank much!

update: let's clients table has throughput read of 10 , throughput write of 10 on primary index. means can read 10 data packages (of 4kb each) per second executing getitem operation have provide primary key only. , can write 10 data packages (of 1kb each) per second executing putitem or update provide primary key way of looking item updated. right?

now, gsi, if put let's read throughput of 4 , write throughput of 4 on global secondary index, mean that: can read maximum (without throttling) of 4 packages (of 4kb each) per second executing getitem operation provide secondary key lookup method. , since not interested in writing down or updating data based on secondary key, because app run update queries or putitems using primary key, able put write throughput of 0 gsi?

or these gsi writes affected changes on primary key operations well? know sure phone number attribute almost never change after item created (unless if change myself using dynamodb manager) or happen make write throughput 1.

yes, how use dynamodb.

the base table schema can hash key email address , no range key.

you can provision global secondary index (gsi) phone number attribute hash key. provisioning level gsi not have match base table, though should provision writes account fact every time item written base table, item (or portion of item) written gsi. if gsi underprovisioned, lead unexpected throttling on base table.

additionally, please aware schema not enforce phone number uniqueness. gsi can have duplicate hash key values, when query gsi may multiple results.

here general documentation on global secondary indexes: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/gsi.html

update: every time make write base table, if attributes appear in schema of gsi present in item, written gsi. gsi second dynamodb table maintained service - requires same write throughput base table if most/all items contain phone numbers.

the operations valid gsi query , scan. retrieve item phone number can use query api condition hash key equal 1 looking for.

in terms of provisioning gsi separately, gsi can have read capacity independent of base table. example:

base table provisioned 10 rcu , 10 wcu

gsi provisioned 1 rcu , 10 wcu.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -