首页 > 解决方案 > Cosmos DB - 较慢的性能问题

问题描述

这些天来,在我们的 cosmos db 中,我们有非分区集合,最近将我们的应用程序数据移动到分区集合以克服单个分区上 10gb 的上限。

在引入分区之后我们注意到的几件事。

  1. ResourceResponse.ContentLocation 属性返回 null。(通常它返回像“dbs/developmentdb/colls/accountmodel”这样的集合路径作为非分区集合的值)

  2. 对于“GetAll”查询(提供在分区和非分区集合中维护的相同数据)

    • RUs 上升(从 400RUs 到 750RUs)
    • 响应时间较慢

供您参考,下面包含使用的代码。感谢您对减少 RU 和提高响应时间 (OR) 的任何建议,这些都是迁移到分区集合的开销吗?请建议

使用的示例代码:

                var docClient = await _documentClient; 
                var docDb = await _documentDatabase;   
                var docCollection = await _documentCollection;

                var queryFeed = new FeedOptions()
                {
                    MaxItemCount = -1,
                    MaxDegreeOfParallelism = -1,
                    EnableCrossPartitionQuery = true
                };

                var documentCollectionUri = UriFactory.CreateDocumentCollectionUri(docDb.Id, docCollection.Id);

                IDocumentQuery<T> query = docClient.CreateDocumentQuery<T>(documentCollectionUri, queryFeed).AsDocumentQuery();

                while (query.HasMoreResults)
                {
                    var page = await query.ExecuteNextAsync<T>();
                    result.AddRange(page);

                    _rULogHelper.LogFromFeedResponse(page, docDb.Id, docCollection.Id, DBOperationType.GET.ToString()); //custom logging related code
                }

标签: azure-cosmosdbazure-cosmosdb-sqlapi

解决方案


推荐阅读