How to use the Table Storage Serviceで説明されているように、いくつかのコードを実装しました。複数のレコードを挿入するために挿入操作の周りにループを作成しました。バッチ挿入を実行したくありません。挿入操作が非常に遅く、6 レコード以下であることがわかりました。秒が挿入されます。コードは、ストレージ サービスを含む同じサブスクリプション内の Azure の仮想マシンで実行されています。レコードを挿入するより速い方法を知っている人はいますか? 私たちのシステムでは定期的に少なくとも 100 件のレコードを保存する必要があります。2番目。
私のコードの一部はここにあります:
public void InsertCustomer(string tableName, CustomerEntity customer)
{
// Create the table client.
CloudTableClient tableClient = _azureQueueStorageAccount.CreateCloudTableClient();
//Get table reference
CloudTable table = tableClient.GetTableReference(tableName);
// Create the TableOperation that inserts the customer entity.
TableOperation insertOperation = TableOperation.Insert(customer);
// Execute the insert operation.
table.Execute(insertOperation);
}
ありがとうパスカル。しかし、ここでは説明していませんが、何らかの理由でバッチ挿入を実行したくありません。私のコードで説明されている通常の挿入がこれほど遅いはずかどうか知っていますか? 挿入される Customer オブジェクトは非常に単純です。
public class CustomerEntity : TableEntity
{
public string Email { get; set; }
public string PhoneNumber { get; set; }
public CustomerEntity(string lastName, string firstName)
{
this.PartitionKey = lastName;
this.RowKey = firstName;
}
public CustomerEntity() { }
}