2
votes

Lets say I have a dynamodb table as:

process_data ( date (hashkey), pid (sortkey), name, status )

I have a global secondary index on 'name'. The write throughput of this GSI is 10. The write capacity of the table is 100.

But when I try to update 'status' using 'date' and 'pid', it results in write throttles. The write rate is greater than 10 but definitely much less than 100. I assumed that as 'name' is not getting updated, the global secondary index on 'name' wouldn't be touched, and write capacity of the index on 'name' wouldn't matter.

Is it that while updating a table, I need to take care of every GSIs, irrespective of whether they are touched or not? Or could something else be causing write throttles? My table is fairly small (around 40MB, so I think partitioning wouldn't affect much).

I read the AWS documentation on provisioning write capacities for GSIs. In one paragraph it says that on updates, GSIs on non-affected keys aren't affected. And in the next para it says while writing to a table ALL write capacities should be taken care of. I found this a bit confusing.

1

1 Answers

3
votes

From what I understood, you have these two index on your table:

  • primary index: date (HK), pid (SK)
  • GSI: name (HK)

Now, coming to the original question: when you create a GSI, think of it as you having a separate table with that GSI. In other words, for the case mentioned above, think of it as you having two different tables in DynamoDB:

  • T1, that has date and pid as HK/SK
  • T2, that has name as HK.

So, what happens when you, say, insert a record in T1 that has a new status field but unchanged name? DynamoDB will still have to write to T2, since the status field for that name now changes. Consequently, you'll eat into the write capacity for T2 as well.

This explanation should also clarify the two doubts you had in the last para of your post.