"How to optimize query performance in Azure Cosmos DB with large JSON documents?"

Ananth Sharma 20 Reputation points
2025-06-12T17:14:20.79+00:00

I'm using Azure Cosmos DB (SQL API) to store large JSON documents (each ~1MB in size). I'm experiencing high RU consumption and latency during queries, especially when filtering on nested properties.

Could you please suggest the best practices to:

Improve query performance with large documents

Use indexing effectively in this case.Also, is it advisable to denormalize or split the data into multiple smaller documents for better efficiency?

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,901 questions
{count} votes

Accepted answer
  1. Sai Raghunadh M 4,635 Reputation points Microsoft External Staff Moderator
    2025-06-12T18:08:09.79+00:00

    Hi @ Ananth Sharma

    Handling large JSON documents in Azure Cosmos DB can be tricky, but there are ways to improve query performance and reduce RU usage:

    Indexing Smartly: Customize indexing to exclude unnecessary properties. Use composite indexing if filtering on multiple fields.

    Better Queries: Avoid SELECT *, filter on indexed properties, and use pagination to handle large results efficiently.

    Partitioning Matters: Pick a partition key that spreads data evenly to avoid hot partitions. Try to keep queries within a single partition.

    Data Structure: If you often need full documents, denormalization could help. If you only query parts of the document, splitting into smaller ones might work better.

    You can check out Microsoft's guide for more details.

    Hope this helps. Do let us know if you any further queries.


    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.