Parent issue: #5747
Problem
CosmosQueryExecutionContextFactory (src/Query/Core/Pipeline/CosmosQueryExecutionContextFactory.cs:515-553) accesses PartitionKeyRange.MinInclusive and .MaxExclusive 6 times when converting ranges to FeedRangeEpk during query pipeline creation. Each access triggers JToken.ToObject<T>() deserialization.
Hot path assessment: WARM
Called once per query execution during pipeline initialization. For applications executing many queries per second, this adds up.
Suggested fix
Cache range.MinInclusive and range.MaxExclusive in local variables, or create a helper method that converts PartitionKeyRange to FeedRangeEpk with a single pair of property accesses.
Lines
CosmosQueryExecutionContextFactory.cs:515-516 range.MinInclusive / range.MaxExclusive (passthrough context)
CosmosQueryExecutionContextFactory.cs:543-544 range.MinInclusive / range.MaxExclusive (full pipeline, first path)
CosmosQueryExecutionContextFactory.cs:552-553 range.MinInclusive / range.MaxExclusive (full pipeline, second path)
Constraint
PartitionKeyRange is in compiled NuGet (Microsoft.Azure.Cosmos.Direct) — fix must be at the call site.
Parent issue: #5747
Problem
CosmosQueryExecutionContextFactory(src/Query/Core/Pipeline/CosmosQueryExecutionContextFactory.cs:515-553) accessesPartitionKeyRange.MinInclusiveand.MaxExclusive6 times when converting ranges toFeedRangeEpkduring query pipeline creation. Each access triggersJToken.ToObject<T>()deserialization.Hot path assessment: WARM
Called once per query execution during pipeline initialization. For applications executing many queries per second, this adds up.
Suggested fix
Cache
range.MinInclusiveandrange.MaxExclusivein local variables, or create a helper method that convertsPartitionKeyRangetoFeedRangeEpkwith a single pair of property accesses.Lines
CosmosQueryExecutionContextFactory.cs:515-516range.MinInclusive/range.MaxExclusive(passthrough context)CosmosQueryExecutionContextFactory.cs:543-544range.MinInclusive/range.MaxExclusive(full pipeline, first path)CosmosQueryExecutionContextFactory.cs:552-553range.MinInclusive/range.MaxExclusive(full pipeline, second path)Constraint
PartitionKeyRangeis in compiled NuGet (Microsoft.Azure.Cosmos.Direct) — fix must be at the call site.