Cosmos mongo db ru based is not able to load the chat

Mansi Gusain 495 Reputation points
2025-05-13T05:27:30.2566667+00:00

Hi, I am using the database - azure cosmos db of the type vcore for my application. All the chats I make with the application are stored in this db. Now in my application if I have to access the chat from 30+ days before then I cannot access it , it takes too long to load but when I run the sql query in the backend it exists. How to decrease the loading time. I am using M10 based db.

User's image

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

1 answer

Sort by: Most helpful
  1. Mallaiah Sangi 1,145 Reputation points Microsoft External Staff Moderator
    2025-05-13T06:56:13.7333333+00:00

    Hi Mansi Gusain,

    Greeting!

    As per my understanding, your application is struggling with retrieving older chats efficiently, even though the data exists in your Azure Cosmos DB vCore database.

    Here are a few ways you might be able to improve the loading time:

    Index Optimization – Ensure your queries take advantage of indexing. If you're frequently querying old chats, consider indexing fields like timestamps or user IDs to speed up retrieval.

    Partitioning Strategy – If your chats are stored in a single large partition, it may slow queries. Consider partitioning data based on date ranges (e.g., monthly partitions) to allow faster lookups.

    Query Optimization – Running a SQL query in the backend might be efficient, but the application-level retrieval may involve additional processing. Try optimizing the query with appropriate filters and projections to fetch only necessary fields.

    Caching Strategies – Implement caching mechanisms (Redis, in-memory caching) for frequently accessed historical chats, reducing repeated database fetches.

    Batching or Pagination – Instead of loading all old chats at once, retrieve smaller batches using pagination, which can significantly improve performance.

    Monitoring Performance Metrics – Use Azure Monitor or Query Performance Insights to identify bottlenecks and adjust configurations accordingly.

    1. Vertical Scaling – If performance issues persist, consider scaling up to a more powerful database tier beyond M10. I hope this information helps. Please do let us know if you have any further queries.
    0 comments No comments

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.