Skip to content

Hierarchical partition keys guidance on Partial PK#363

Open
ananth7592 wants to merge 1 commit intoMicrosoftDocs:mainfrom
ananth7592:ananth/fix-hpk-query-docs
Open

Hierarchical partition keys guidance on Partial PK#363
ananth7592 wants to merge 1 commit intoMicrosoftDocs:mainfrom
ananth7592:ananth/fix-hpk-query-docs

Conversation

@ananth7592
Copy link
Copy Markdown

No description provided.

@ananth7592 ananth7592 changed the title Hierarhcical partition keys guidance on Partial PK Hierarchical partition keys guidance on Partial PK Apr 14, 2026
@prmerger-automator prmerger-automator bot requested a review from deborahc April 14, 2026 19:48
@prmerger-automator
Copy link
Copy Markdown
Contributor

@ananth7592 : Thanks for your contribution! The author(s) and reviewer(s) have been notified to review your proposed change.

@prmerger-automator
Copy link
Copy Markdown
Contributor

@ananth7592 : Thanks for your contribution! The author(s) and reviewer(s) have been notified to review your proposed change.

@learn-build-service-prod
Copy link
Copy Markdown
Contributor

Learn Build status updates of commit ea7d712:

✅ Validation status: passed

File Status Preview URL Details
articles/cosmos-db/hierarchical-partition-keys.md ✅Succeeded

For more details, please refer to the build report.

When the query specifies all values of the partition keys in the `WHERE` filter or in a prefix of the key hierarchy, the SDK automatically routes the query to the corresponding physical partitions. Queries that provide only the "middle" of the hierarchy are cross-partition queries.

For queries intending to use a partial prefix of the hierarchical partition key path, you must explicitly include the partial prefix in the **WHERE** clause to be efficiently routed. Relying solely on supplying values via `PartitionKeyBuilder` does not currently guarantee efficient query execution. Queries that omit the partition key in the **WHERE** clause might incur significantly higher RU costs.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an example?

Copy link
Copy Markdown
Author

@ananth7592 ananth7592 Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are already existing examples just below this section that cover this scenario. https://learn.microsoft.com/en-us/azure/cosmos-db/hierarchical-partition-keys?tabs=net-v3%2Cbicep#run-a-query

Please take a look and let me know if they make sense for the guidance

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of the examples explicitly mention hierarchical PK, may be we need to clarify existing example or add a new one.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example below is covering the where clause condition that is being mentioned in the guidance

SELECT * FROM c WHERE c.TenantId = 'Microsoft' | Routed to only the targeted subset of logical and physical partition(s) that contain data for the specified value of TenantId. This query is a targeted cross-partition query that returns data for all users in a tenant. -- | --

@v-regandowner
Copy link
Copy Markdown
Contributor

@deborahc

Can you review the proposed changes?

IMPORTANT: When the changes are ready for publication, adding a #sign-off comment is the best way to signal that the PR is ready for the review team to merge.

#label:"aq-pr-triaged"
@MicrosoftDocs/public-repo-pr-review-team

@prmerger-automator prmerger-automator bot added the aq-pr-triaged C+L Pull Request Review Team label label Apr 14, 2026
@v-regandowner v-regandowner requested a review from Copilot April 14, 2026 20:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds guidance to the hierarchical partition keys documentation to clarify query routing behavior when only a prefix of the hierarchical partition key is provided.

Changes:

  • Documented that partial-prefix query routing requires the prefix to be present in the WHERE clause
  • Warned that relying only on PartitionKeyBuilder may not ensure efficient routing and can increase RU costs

Comment thread articles/cosmos-db/hierarchical-partition-keys.md Outdated
@ananth7592 ananth7592 force-pushed the ananth/fix-hpk-query-docs branch from ea7d712 to f865b0e Compare April 14, 2026 22:59
@learn-build-service-prod
Copy link
Copy Markdown
Contributor

Learn Build status updates of commit f865b0e:

✅ Validation status: passed

File Status Preview URL Details
articles/cosmos-db/hierarchical-partition-keys.md ✅Succeeded

For more details, please refer to the build report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants