Delete hundreds of objects from Azure table storage

My colleague and I are currently implementing a undo / redo function for products. We use the command template and save each command (for example, create the myFancyComponent component) as a TableStorageEntry in the "ProductHistory" table. PartitionKey in this table is the unique name of the product, RowKey is the unique identifier.

The problem is that the product is being deleted, it must also delete the entire history in the table storage. Using batch deletion can be quite difficult, as there are several limitations: max. 100 objects or max. 4 MB (which is less). Is there any best practice for this problem? Or is it the only solution to query all records and check the size of the records and batch delete the desired number of records?

I also found this similiar question and decided to create a table for EVERY product. There seem to be some advantages to this approach:

  • The choice should be faster because only one table will be requested
  • Removing is easy, just need to delete the whole table

The only flaw I found (in "WINDOWS AZURE TABLE" is white paper):

  • Note that when a table is deleted, the same table name cannot be recreated for at least 30 seconds, while the table collects garbage.

Are there any other problems (performance) if I create several hundred tables?

+4
source share
1 answer

I would highly recommend a single table approach for each product, since you indicated that it would quickly eliminate the need for batch processing of transactions for deletion, and if you want to remove the 30 second limit, you just need to have an index table that stores the relationship between the tables and their products. You can then mark the product as deleted and reassign its table when re-added. Thus, a simple bypass of the 30 second limit is provided. Another approach (which I also recommended) is to separate the addition of products so that it happens asynchronously, so you can just wait to create a table when the name is available again.

As for performance issues, there shouldn't be any problems, even if you have thousands of tables in which you don't exceed the current limit of 5,000 transactions per second on your Azure storage account. :)

+8
source

Source: https://habr.com/ru/post/1403854/


All Articles