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.
- 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.