6

Coming from a relational background, I'm used to being able to write something like:

UPDATE Table Set X = 1 Where Y = 2

However such an operation seems very difficult to accomplish in a db like Dynamodb. Let's say I have already done a query for the items where Y = 2.

The way I see it, with the API provided there are two options:

  • Do lots and lots of individual update requests, OR
  • Do a batch write and write ALL of the data back in, with the update applied.

Both of these methods seem terrible, performance-wise.

Am I missing something obvious here? Or are non relational databases not designed to handle 'updates' on this scale - and if so, can I achieve something similar without drastic performance costs?

Community
  • 1
  • 1
Daniel
  • 1,125
  • 2
  • 9
  • 21

1 Answers1

11

No, you are not missing anything obvious. Unfortunately those are the only options you have with DynamoDB, with one caveat being that a BatchWrite is only capable of batch submitting 25 update operations at a time so you'll still have to potentially issue multiple BatchWrite requests.

A BatchWrite is more of a convenience that the DynamoDB API offers to help you save on network traffic, reducing the overhead of 25 requests to the overhead of one, but otherwise it's not much savings.

The BatchWrite API is also a bit less flexible than the individual Update and Put item APIs so in some situations it's better to handle the concurrency yourself and just use the underlying operations.

Of course, the best scenario is if you can architect your solution such that you don't need to perform massive updates to a DynamoDB table. Writes are expensive and if you find yourself frequently having to update a large portion of a table, chances are that there is an alternative design that could be employed.

Mike Dinescu
  • 54,171
  • 16
  • 118
  • 151
  • What can be alternate design if problems is like bulk change of status, or bulk upload of inventories? – ManMohan Vyas Jul 18 '17 at 11:54
  • @ManMohanVyas alternatives depend on your problem space. What is it exactly that you are trying to do? – Mike Dinescu Jul 18 '17 at 15:26
  • As mentioned trying to bulk upload inventories from csv. On bulk change on status in thousand of inventories. with inventory management domain these are very common problem – ManMohan Vyas Jul 19 '17 at 07:45
  • @ManMohanVyas thousands of items is not a problem for Dynamo. And if those are from CSV it seems to me like you can allow the update to proceed over a few minutes, making it effectively free (not to mention there is burst available). But why is your system using two data sources? What updates the CSV? Can that not be integrated with the DynamoDB? – Mike Dinescu Jul 19 '17 at 15:10
  • You got it incorrect use case is - 1) Upload inventories from GUI to dynamodb. 2) On Inventories that are already present in dynamoDB perform a bulk update of some inventory property. Note- I am only using dynamo - but search of inventories, update of inventories seems not to be efficient – ManMohan Vyas Jul 19 '17 at 20:58