Clarify optimizer-controlled predicate ordering in FTS guidance - #266
Open
Vsevolod Kukol (sevoku) wants to merge 2 commits into
Open
Vsevolod Kukol (sevoku) wants to merge 2 commits into
Vsevolod Kukol (sevoku) wants to merge 2 commits into
Conversation
Vsevolod Kukol (sevoku)
requested review from
Theo van Kraay (TheovanKraay),
Jay Gordon (jaydestro) and
Sajeetharan (sajeetharan)
as code owners
September 22, 2026 13:28
Copilot started reviewing on behalf of
Vsevolod Kukol (sevoku)
September 22, 2026 13:34
View session
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Reconcile contradictory filter-order guidance and bump the required metadata versions.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
This PR clarifies Cosmos DB FTS guidance by removing claims that SQL predicate order controls evaluation performance.
Changes:
- Emphasizes selective indexed filters and partition scoping.
- Updates the FTS rule and
SKILL.mdoverview with indexing documentation.
| File | Reviewed changes and findings |
|---|---|
skills/cosmosdb-best-practices/SKILL.md |
Updates the FTS summary. Nit (1 vote): bump the package and skill metadata version. |
skills/cosmosdb-best-practices/rules/fts-hybrid-queries.md |
Clarifies filtering and optimizer-controlled ordering. Moderate (3 votes): reconcile the contradiction with query-order-filters.md. Nit (1 vote): bump package and skill metadata versions. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Vsevolod Kukol (sevoku)
marked this pull request as draft
September 22, 2026 13:38
Vsevolod Kukol (sevoku)
marked this pull request as ready for review
September 22, 2026 14:37
Copilot started reviewing on behalf of
Vsevolod Kukol (sevoku)
September 22, 2026 14:42
View session
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Repository manifests need an atomic version bump for the substantially revised rule.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
Resolved since last review (1)
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Remove the claim that placing selective predicates earlier in the
WHEREclause improves Cosmos DB query performance. Reconcilefts-hybrid-queries.md, the generalquery-order-filters.mdrule, and theirSKILL.mdoverview entries.Problem
The FTS rule tells readers to put the most restrictive filter first, while the general filter rule explicitly claims left-to-right execution and invents intermediate row counts for equivalent queries. Both are indexed in the skill. This conflates adding useful filters with controlling evaluation order through SQL text and would leave conflicting instructions if only the FTS rule were corrected.
Selective indexed filters can narrow the matching document set, and a partition-key equality filter can scope a query to that partition. Reordering equivalent predicates is not the optimization: Cosmos DB's query engine determines predicate evaluation order.
Changes
The FTS SQL and Java examples are unchanged. The general rule's examples now make clear that reordered predicates are equivalent, not a cheaper execution plan; fabricated intermediate row counts and fixed selectivity rankings are removed. Its filename and links remain stable, and both indexed rules now provide consistent optimizer-controlled guidance.
Documentation Evidence
Microsoft's Cosmos DB indexing overview explicitly states:
This is Cosmos DB-specific guidance, not an assumption based on other SQL engines. The correction does not promise a fixed RU reduction or a particular execution sequence.
Original Discussion And Scope
Addresses the original review discussion on microsoft/vscode-cosmosdb#3355, where the skill is vendored into the VS Code extension.
The follow-up review about contradictory general filter guidance is resolved by 798fcab, which includes the general-rule correction in this PR rather than leaving contradictory guidance in a companion rule.
Changes are limited to the two filter-order rules and their overview entries. Other indexing findings are being handled separately; version metadata is unchanged.