Container1という名前のAzure Cosmos DB for NoSQLコンテナがあり、500GBのデータが格納されています。 Container1を対象とするクロスパーティションクエリを実行する予定です。これらのクエリには、データベースフィルタで指定されたパーティションキー値が含まれます。 クエリのコストを最小限に抑える必要があります。 あなたはどうすべきですか?
正解:D
To keep the price (RU cost) of your queries low in an Azure Cosmos DB for NoSQL container with hundreds of GB of data, the correct action is: Add the IN keyword to the queries. Why it works: Using the IN keyword allows you to provide a specific list of partition key values in the query's WHERE clause. Cost reduction: By specifying partition keys, the query engine can route the request only to the specific physical partitions that hold those values. Efficiency: This avoids a full "fan-out" query (visiting every physical partition in a container with hundreds of GBs), which is the most expensive way to query Cosmos DB. Incorrect: [Not A] Decrease the value of the MaxBufferedItemCount parameter: This parameter controls how many items the client-side SDK buffers during a cross-partition query to manage memory and latency. It does not reduce the Request Unit (RU) cost charged by the database. [Not B] Add the DISTINCT keyword to the queries: The DISTINCT keyword often increases the RU cost because the query engine must perform extra work to identify and remove duplicate values across multiple partitions. [Not C] Decrease the value of the MaxConcurrency parameter: MaxConcurrency limits the number of simultaneous network requests the SDK makes to different partitions. While it can help manage client-side resources and avoid rate limiting, it does not reduce the total RU cost of the query execution on the server side. Reference: https://learn.microsoft.com/en-us/azure/cosmos-db/performance-tips-query-sdk