What is the way to delete a large number of items from DynamoDB?

What is the way to delete a large number of items from DynamoDB?

Asked on October 27, 2018 in Database.
Add Comment


  • 5 Answer(s)

    Here is the best way to avoid the cost of a full scan:

    •      Use the query instead of Scan to retrieve all things for user_id – this works despite the combined hash/range primary key in use, as a result of HashKeyValue and RangeKeyCondition ar separate parameters during this API and therefore the former solely targets the Attribute price of the hash part of the composite primary key..
    • Loop over all came back things and either facilitate DeleteItem as was common
    Answered on October 27, 2018.
    Add Comment

    In dynamoDB documentation you could just delete the full table.

    we could delete a table in the Java by the use of AWS SDK:

    DeleteTableRequest deleteTableRequest = new DeleteTableRequest()
        .withTableName(tableName);
    DeleteTableResult result = client.deleteTable(deleteTableRequest);
    

     

    Answered on October 27, 2018.
    Add Comment

    Maximum operations during a single request — we’ll be able to specify a complete of up to twenty five place or delete operations; but, the full request size cannot exceed one MB (the protocol payload).

    Not associate atomic operation — Individual operations per the Batch Write Item square measure atomic; but Batch Write Item as an entire could be a “best-effort” operation associated not an atomic operation. That is, during a Batch Write Item request, some operations would possibly succeed et al would possibly fail. […]

    Answered on October 27, 2018.
    Add Comment

     

    “Deleting an entire table is significantly more efficient than removing items one-by-one, which essentially doubles the write throughput as you do as many delete operations as put operations”

    If you wish to delete only a subset of your data, then you could make separate tables for each month, year or similar. This way you could remove “last month” and keep the rest of your data intact.

    This is how you delete a table in Java using the AWS SDK:

    DeleteTableRequest deleteTableRequest = new DeleteTableRequest()
      .withTableName(tableName);
    DeleteTableResult result = client.deleteTable(deleteTableRequest);
    Answered on January 14, 2019.
    Add Comment

    Based on the API, there is no Batch Delete for DynamoDB.

    http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html

    You need to query the item and delete with their partition key.

    I would recommend looking at ODM,

    https://github.com/clarkie/dynogels

    to make the operations simpler.

    Check out the sample calls for deletion,

    Account.destroy('[email protected]', function (err) {
      console.log('account deleted');
    });
    
    // Destroy model using hash and range key
    BlogPost.destroy('[email protected]', 'Hello World!', function (err) {
      console.log('post deleted')
    });
    
    BlogPost.destroy({email: '[email protected]', title: 'Another Post'}, function (err) {
      console.log('another post deleted')
    });
    Answered on January 14, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.