Reputation: 17
I got a question for using GSI in dynamoDB, I got 10 attributes in a table using 2 GSI and I want to retrieve the same data for both GSI with a different access pattern
For example :
Main table
userId, productId, productName, price, GSI1,GS2, more attributes.
GSI: projected attributes all get product by product name PK: productName, sk : price
GSI: projected attributes all get product by price and name PK: price, sk : product name
both GSI projects the same 10 table attributes, but my question both GSI are independent each other for storage, because as I may know each GSI has it's own WUC,RUC but is the same for storage because they are projecting the same values ?
What's the best practice to use only Keys, ALL, include with a GSI ? any example or guide
thanks a lot.
Upvotes: 0
Views: 1088
Reputation: 8885
The storage is per GSI. A GSI is effectively a hidden table that is synchronized automatically.
There is good information on GSIs at General Guidelines for Secondary Indexes in DynamoDB.
Because secondary indexes consume storage and provisioned throughput, you should keep the size of the index as small as possible. Also, the smaller the index, the greater the performance advantage compared to querying the full table. If your queries usually return only a small subset of attributes, and the total size of those attributes is much smaller than the whole item, project only the attributes that you regularly request.
Upvotes: 2