简体   繁体   English

Microsoft.Azure.Cosmos.Table 和 Microsoft.WindowsAzure.Storage 之间的 ExecuteQuerySegmentedAsync 性能显着下降

[英]Significant performance degration on ExecuteQuerySegmentedAsync between Microsoft.Azure.Cosmos.Table and Microsoft.WindowsAzure.Storage

I've been researching moving from Storage Account table storage to CosmosDB table storage.我一直在研究从存储帐户表存储迁移到 CosmosDB 表存储。 Currently I am using the WindowsAzure.Storage (9.3.3) library to query data in a .net core 3.1 application.目前我正在使用 WindowsAzure.Storage (9.3.3) 库来查询 .net 核心 3.1 应用程序中的数据。 As part of this migration I have switched to the Microsoft.Azure.Cosmos.Table 1.0.7 library.作为此迁移的一部分,我已切换到 Microsoft.Azure.Cosmos.Table 1.0.7 库。 I wrote the LinqPad benchmark below to compare the performance of both when doing a full table scan.我在下面编写了 LinqPad 基准测试来比较两者在进行全表扫描时的性能。

async Task Main()
{
    var timer = Stopwatch.StartNew();
    await QueryCosmosDb().ConfigureAwait(false);
    timer.Stop();
    var cosmosExecutionTime = timer.Elapsed;

    timer = Stopwatch.StartNew();
    await QueryTableStorage().ConfigureAwait(false);
    timer.Stop();
    var tableExecutionTime = timer.Elapsed;
    
    cosmosExecutionTime.Dump();
    tableExecutionTime.Dump();
}

public async Task QueryCosmosDb()
{
    var cosmosTableEndpoint = new Uri($"https://***.table.cosmos.azure.com:443/");
    var storageAccount = new Microsoft.Azure.Cosmos.Table.CloudStorageAccount(new Microsoft.Azure.Cosmos.Table.StorageCredentials("***", "****"), cosmosTableEndpoint);
    var client = storageAccount.CreateCloudTableClient();
    var table = client.GetTableReference("tablename");
    var query = new Microsoft.Azure.Cosmos.Table.TableQuery();
    Microsoft.Azure.Cosmos.Table.TableContinuationToken token = null;
    do
    {
        var segment = await table.ExecuteQuerySegmentedAsync(query, token).ConfigureAwait(false);
        token = segment.ContinuationToken.Dump();
    }
    while (token != null);
}

public async Task QueryTableStorage()
{
    var storageAccount = new Microsoft.WindowsAzure.Storage.CloudStorageAccount(new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials("***", "****"), true);
    var client = storageAccount.CreateCloudTableClient();
    var table = client.GetTableReference("tablename");
    var query = new Microsoft.WindowsAzure.Storage.Table.TableQuery();
    Microsoft.WindowsAzure.Storage.Table.TableContinuationToken token = null;
    do
    {
        var segment = await table.ExecuteQuerySegmentedAsync(query, token).ConfigureAwait(false);
        token = segment.ContinuationToken;
    }
    while (token != null);
}

The Storage Account table and CosmosDb table have an identical datasets of roughly 200k entities.存储帐户表和 CosmosDb 表具有大约 200k 个实体的相同数据集。

The Cosmos Table Account has a shared provision throughput of 2200 RUs. Cosmos 表帐户的共享供应吞吐量为 2200 RU。

When using the Cosmos Executor with the Microsoft.Azure.Cosmos.Table library I am getting an execution time of ~3 hours.将 Cosmos Executor 与 Microsoft.Azure.Cosmos.Table 库一起使用时,执行时间约为 3 小时。 The Storage Account table with the Microsoft.WindowsAzure.Storage library takes ~2 minutes.带有 Microsoft.WindowsAzure.Storage 库的存储帐户表大约需要 2 分钟。 If I switch the Microsoft.Azure.Cosmos.Table library to use the rest executor in the Cloud Table Client I get an execution time of ~3 minutes.如果我在 Cloud Table 客户端中切换 Microsoft.Azure.Cosmos.Table 库以使用 rest 执行器,我会得到约 3 分钟的执行时间。

Has anyone encountered similar behavior or aware of issues around empty table queries?有没有人遇到过类似的行为或意识到空表查询的问题?

Also added ticket to Github Issues in azure-cosmos-table-dotnet还添加了azure-cosmos-table-dotnet中 Github 问题的票证

Its the internal implementation for the ExecuteQuery method which is causing the time difference, so there's no chance we could fix the issue unless Microsoft notices and fixes the issue in the upcoming release, anyways now that they have deprecated and using common library Microsoft.Azure.Cosmos it must've solved the issue, hope this helps它是导致时差的 ExecuteQuery 方法的内部实现,因此除非 Microsoft 注意到并在即将发布的版本中修复了该问题,否则我们没有机会解决该问题,无论如何,现在他们已弃用并使用通用库Microsoft.Azure.Cosmos它一定已经解决了这个问题,希望这有帮助

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure function,缺少 Microsoft.WindowsAzure.Storage - Azure function, Microsoft.WindowsAzure.Storage missing 无法加载文件或程序集“ Microsoft.WindowsAzure.Storage” Azure函数 - Could not load file or assembly 'Microsoft.WindowsAzure.Storage' Azure Functions OperationContext 使用情况 (Microsoft.WindowsAzure.Storage) - OperationContext usage (Microsoft.WindowsAzure.Storage) 如何用 Microsoft.Azure.Storage.Blob 替换 Microsoft.WindowsAzure.Storage - How to replace Microsoft.WindowsAzure.Storage with Microsoft.Azure.Storage.Blob Microsoft.Azure.Cosmos.Table LocationMode.SecondaryOnly RA-GRS Exception 此操作只能针对主存储位置执行 - Microsoft.Azure.Cosmos.Table LocationMode.SecondaryOnly RA-GRS Exception This operation can only be executed against the primary storage location 升级到Microsoft.WindowsAzure.Storage 4.0.0后,表实体未正确序列化 - Table entities not being serialized properly after upgrade to Microsoft.WindowsAzure.Storage 4.0.0 了解“无法解决的”Microsoft.WindowsAzure.Storage“不同版本之间发现冲突”的构建日志。 - Understanding build log for “Found conflicts between different versions of ”Microsoft.WindowsAzure.Storage“ that could not be resolved.” HRESULT:0x80131040-找不到Microsoft.WindowsAzure.Storage - HRESULT: 0x80131040 - Microsoft.WindowsAzure.Storage not found Microsoft.WindowsAzure.Storage和System.Net.Http发生冲突 - Microsoft.WindowsAzure.Storage and System.Net.Http conflict Microsoft.WindowsAzure.Storage 是否符合 FIPS 140-2 - Can Microsoft.WindowsAzure.Storage be FIPS 140-2 compliant
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM