Skip to content
Skills Library
Data & analytics · Analysis

cosmosdb-query-optimization

/cosmosdb-query-optimization

Azure Cosmos DB query optimization best practices: point reads, projections, pagination with continuation tokens, parameterized queries, filter ordering, cross-partition query avoidance, and analytical query detection. USE FOR: Cosmos DB queries, point reads vs queries, SELECT projections, continuation tokens, parameterized queries, avoid cross-partition, avoid scans, filter selectivity, TOP literal, ORDER BY, latest by timestamp, OLAP detection, aggregate queries, DISTINCT keyword. DO NOT USE FOR: indexing (use cosmosdb-indexing), data modeling (use cosmosdb-data-modeling), SDK client code (u

Licence
MIT
Last repository change
27.10.2026

Assessment and security

90/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content25 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
13
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 27.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Azure Cosmos DB query optimization best practices: point reads, projections, pagination with continuation tokens, parameterized queries, filter ordering, cross-partition query avoidance, and analytical query detection. USE FOR: Cosmos DB queries, point reads vs queries, SELECT projections, continuation tokens, parameterized queries, avoid cross-partition, avoid scans, filter selectivity, TOP literal, ORDER BY, latest by timestamp, OLAP detection, aggregate queries, DISTINCT keyword. DO NOT USE FOR: indexing (use cosmosdb-indexing), data modeling (use cosmosdb-data-modeling), SDK client code (u

Original author description

Azure Cosmos DB query optimization best practices: point reads, projections, pagination with continuation tokens, parameterized queries, filter ordering, cross-partition query avoidance, and analytical query detection. USE FOR: Cosmos DB queries, point reads vs queries, SELECT projections, continuation tokens, parameterized queries, avoid cross-partition, avoid scans, filter selectivity, TOP literal, ORDER BY, latest by timestamp, OLAP detection, aggregate queries, DISTINCT keyword. DO NOT USE FOR: indexing (use cosmosdb-indexing), data modeling (use cosmosdb-data-modeling), SDK client code (u

How it works

  1. When to Apply
  2. Rules
Original SKILL.md headings · 29 lines, 154 words
SKILL.md preview
---
name: cosmosdb-query-optimization
description: >
  Azure Cosmos DB query optimization best practices: point reads, projections,
  pagination with continuation tokens, parameterized queries, filter ordering,
  cross-partition query avoidance, and analytical query detection.
  USE FOR: Cosmos DB queries, point reads vs queries, SELECT projections,
  continuation tokens, parameterized queries, avoid cross-partition, avoid scans,
  filter selectivity, TOP literal, ORDER BY, latest by timestamp, OLAP detection,
  aggregate queries, DISTINCT keyword.
  DO NOT USE FOR: indexing (use cosmosdb-indexing), data modeling (use cosmosdb-data-modeling),
  SDK client code (use cosmosdb-sdk).
---

# Azure Cosmos DB Query Optimization

Best practices for writing efficient queries against Azure Cosmos DB.

## When to Apply

Reference these guidelines when:
- Writing or optimizing Cosmos DB queries
- Implementing pagination
- Choosing between point reads and queries
- Reducing RU consumption on read operations
- Handling aggregations and sorting

## Rules

- [query-point-reads](references/query-point-reads.md) - Use point reads when id and partition key are known
- [query-aggregate-single-pass](references/query-aggregate-single-pass.md) - Compute min/max/avg with one scoped aggregate query
- [query-avoid-cross-partition](references/query-avoid-cross-partition.md) - Minimize cross-partition queries
- [query-use-projections](references/query-use-projections.md) - Project only needed fields
- [query-pagination](references/query-pagination.md) - Use continuation tokens for pagination
- [query-avoid-scans](references/query-avoid-scans.md) - Avoid full container scans
- [query-parameterize](references/query-parameterize.md) - Use parameterized queries
- [query-order-filters](references/query-order-filters.md) - Order filters by selectivity
- [query-top-literal](references/query-top-literal.md) - Use literal integers for TOP
- [query-latest-by-timestamp](references/query-latest-by-timestamp.md) - Query latest documents with ORDER BY and TOP 1
- [query-olap-detection](references/query-olap-detection.md) - Detect and redirect analytical queries
- [query-distinct-keyword](references/query-distinct-keyword.md) - Use DISTINCT keyword correctly
Files in this package (13)
  • SKILL.md 2 KB
  • references/query-aggregate-single-pass.md 3 KB
  • references/query-avoid-cross-partition.md 4 KB
  • references/query-avoid-scans.md 3 KB
  • references/query-distinct-keyword.md 2 KB
  • references/query-latest-by-timestamp.md 2 KB
  • references/query-olap-detection.md 5 KB
  • references/query-order-filters.md 3 KB
  • references/query-pagination.md 8 KB
  • references/query-parameterize.md 4 KB
  • references/query-point-reads.md 8 KB
  • references/query-top-literal.md 2 KB
  • references/query-use-projections.md 6 KB

Versions

The database has no other skills named cosmosdb-query-optimization.

Database snapshot: 13.11.2026 · package version ff9db34994ac (SHA-256 digest of the entire package)

Downloads in the last 30 days: 1 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100cosmosdb-best-practices
    Azure Cosmos DB performance optimization and best practices guidelines for NoSQL, partitioning, queries, and SDK usage. Use when writing, reviewing, or refactoring code that interacts with Azure Cosmos DB, designing data models, optimizing queries, or implementing…
  • 100cosmosdb-best-practices
    Azure Cosmos DB performance optimization and best practices guidelines for NoSQL, partitioning, queries, and SDK usage. Use when writing, reviewing, or refactoring code that interacts with Azure Cosmos DB, designing data models, optimizing queries, or implementing…
  • 90azure-cosmosdb-application-developer
    Use this skill for Azure Cosmos DB application development work, especially NoSQL data modeling, document structure, partition-aware access patterns, point reads, query design, SDK usage, transactional batch scope, consistency-aware reads, change feed integration, and Cosmos DB development guidance.
  • 90cosmosdb-data-modeling
    Azure Cosmos DB data modeling best practices: embedding vs referencing, document size limits, schema versioning, type discriminators, JSON serialization, denormalization, and relationship patterns. USE FOR: Cosmos DB document design, embedding related data, referencing large…
  • 90cosmosdb-data-modeling-workflow
    Step-by-step guide for designing Azure Cosmos DB NoSQL data models. Captures application requirements, access patterns, volumetrics, and concurrency details into a cosmosdb_requirements.md file, then produces an optimized Cosmos DB NoSQL data model design using best practices…
  • 95cosmosdb-best-practices
    Azure Cosmos DB performance optimization and best practices guidelines for NoSQL, partitioning, queries, SDK usage, and vector search. Use when writing, reviewing, or refactoring code that interacts with Azure Cosmos DB, designing data models, optimizing queries, or implementing…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.