I use the MergeOption.NoTracking parameter on the DataServiceContext.MergeOption for extra performance if I am not going to update the object any time soon. Here is an example:
var account = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("DataConnectionString")); var tableStorageServiceContext = new AzureTableStorageServiceContext(account.TableEndpoint.ToString(), account.Credentials); tableStorageServiceContext.RetryPolicy = RetryPolicies.Retry(3, TimeSpan.FromSeconds(1)); tableStorageServiceContext.MergeOption = MergeOption.NoTracking; tableStorageServiceContext.AddObject(AzureTableStorageServiceContext.CloudLogEntityName, newItem); tableStorageServiceContext.SaveChangesWithRetries();
Another problem may be that you are extracting all enity with all its properties, even if you intend to use only one or two properties - this, of course, is wasteful, but cannot be easily fixed. However, if you use Slazure , you can only use query predictions to retrieve the properties of the object that interest you from the table storage and nothing else that will give you better query performance. Here is an example:
using SysSurge.Slazure; using SysSurge.Slazure.Linq; using SysSurge.Slazure.Linq.QueryParser; namespace TableOperations { public class MemberInfo { public string GetRichMembers() {
Full disclosure: I encoded Slazure.
You can also consider pagination if you are retrieving large datasets, for example:
user152949
source share