I have an Azure Storage Table and it has 3k+ records.
What is the most efficient way to delete all the rows in the table?
I have an Azure Storage Table and it has 3k+ records.
What is the most efficient way to delete all the rows in the table?
This depends on the structure of your data, but if you can compose a query for all records, you can add each to a TableBatchOperation
and execute them all at once.
Here's an example that just gets all the results inside the same partition key, adapted from How to get started with Azure Table storage and Visual Studio connected services.
<!-- language: lang-cs -->// query all rows
CloudTable peopleTable = tableClient.GetTableReference("myTableName");
var query = new TableQuery<MyTableEntity>();
var result = await remindersTable.ExecuteQuerySegmentedAsync(query, null);
// Create the batch operation.
TableBatchOperation batchDeleteOperation = new TableBatchOperation();
foreach (var row in result)
{
batchDeleteOperation.Delete(row);
}
// Execute the batch operation.
await remindersTable.ExecuteBatchAsync(batchDeleteOperation);