Reputation: 1724
I can insert an Object(annotated with @DynamoDBTable) in DynamoDB using to following code
@Autowired
private SdnInformationRepository sdnInformationRepository;
SdnInformation inf = new SdnInformation();
inf.setFirstName("firstname");
inf.setLastName("lastname");
sdnInformationRepository.save(inf);
Here is my repository
public interface SdnInformationRepository extends
CrudRepository<SdnInformation, String> {
}
and my model
@DynamoDBTable(tableName = "SdnList")
public class SdnInformation {
@DynamoDBHashKey(attributeName = "Id")
@DynamoDBAutoGeneratedKey
private String id;
private String firstName;
private String lastName;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}
Everything works fine here. I want to know whether it is possible to insert a List/Set of SdnInformation objects at once? If I insert a huge number of such objects individually it takes too much time. So I want something like
Set<SdnInformation> listToInsert = new HashSet<SdnInformation>();
... some code to fill my set with thousands of objects ...
sdnInformationRepository.save(listToInsert);
Upvotes: 1
Views: 1068
Reputation: 55730
DynamoDB does not support inserting multiple items at the same time. Batching multiple requests (up to 25) is possible but they are still considered separate requests by Dynamo (ie it is possible for some to succeed and some to fail).
Of course, at a high level, a mapper can pretend that it is inserting a list of items but underlying there will still be separate operations.
Update (based on comment)
If it’s speed you’re after, you can parallelize the inserts. As long as you have write capacity available you can get a lot of speed improvement that way. But it can get expensive fast. And there is a limit of 1000 inserts/second per partition.
Upvotes: 1