Open lisad opened 11 years ago
Dynamodb batch queries are limited to 25 items, so the solution would also have to break large arrays up into 25 item batches.
Hi Lisa,
That seems reasonable. I speculate the changes you need to make are twofold and about what you outline: 1) Changes to criteria/chain.rb to properly detect that a batch_get is possible based on the where conditions 2) Changes to adapter/aws_sdk.rb to be smart about using batch_get when given a set of keys
If you're up for putting together a PR, I suggest:
Hope this helps!
ActiveRecord supports "subset conditions", e.g. http://edgeguides.rubyonrails.org/active_record_querying.html has the example:
DynamoDB supports "BatchGet" : http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/DynamoDB/BatchGet.html
It would seem to be a good matchup. Dynamoid does not currently support this. When I attempt the DynamoidThing.where(id: array_of_ids) syntax, it fails in Dynamoid::Adapter::AwsSdk.query, which is documented to only support one hash key.
If this is a good fit and Dynamoid should be extended to support it, any suggestions how to integrate it? I would propose either in Dynamoid::Adapter.query or Dynamoid::Adapter::AwsSdk.query, detect the Array passed in and branch off the logic. Then in Dynamoid::Adapter::AwsSdk, create a new "batch_query" method that uses batch_get something like this (untested, just a sketch)