Skip to content

Perf: PartitionRoutingHelper accesses PartitionKeyRange MinInclusive/MaxExclusive during split/continuation handling #5752

@kirankumarkolli

Description

@kirankumarkolli

Parent issue: #5747

Problem

PartitionRoutingHelper (src/Routing/PartitionRoutingHelper.cs) accesses PartitionKeyRange.MinInclusive and .MaxExclusive at lines 268, 377, and 379 during partition split handling and continuation token processing. Each access triggers JToken.ToObject<T>() deserialization.

Hot path assessment: WARM

Called per-query when resuming from continuation tokens or handling partition splits. Not per-item, but can be frequent in high-throughput query scenarios with many partitions.

Suggested fix

Cache the property values in local variables before use, or leverage Range<string> objects that already contain materialized Min/Max strings.

Lines

  • PartitionRoutingHelper.cs:268 replacedRanges[0].MinInclusive and replacedRanges[...].MaxExclusive in validation
  • PartitionRoutingHelper.cs:377 currentRange.MaxExclusive in comparison
  • PartitionRoutingHelper.cs:379 currentRange.MaxExclusive repeated access

Constraint

PartitionKeyRange is in compiled NuGet (Microsoft.Azure.Cosmos.Direct) fix must be at the call site.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions