Please stop using MongoDB for analytics....
It's not uncommon to see companies using their transaction system (OLTP) to perform analytics.This works until it doesn't.
There is a reason OLAP systems became popularized and its not because we like spending all day trying to duplicate data from one database to another.
OLAP systems(which aren't always your traditional data warehouse) are optimized to run OLAP queries and be a little more friendly to the end-user.
Here is a slightly deeper dive into the difference between OLTP vs OLAP.Access PatternsThe access pattern of an OLTP system is characterized by a high volume of small, frequent transactions that require fast response times and concurrent access by multiple users.
The access pattern of an OLAP system is characterized by fewer, larger, and more complex queries that require longer response times but provide greater analytical capabilities.
Data Model
OLTP systems typically use a normalized data model, where data is organized into multiple tables and relationships. Normalization reduces redundancy and ensures data consistency. Of course this is different when referring to MongoDB and other similar DBs.
OLAP data models tend to be more denormalized. This should reducethe number of joins required and generally make it easier for an analyst to understand how to write their query.
Size
OLTPs tend to be smaller in terms of memory since they might only hold the current data and not historical changes.
OLAPs will be larger as they will store historical data as well asdata from multiple systems.
Performance
OLTPs need to have fast response times. Otherwise, end-users would be concerned that their tweet didn't go through
OLAP systems can get away with being a little slower.
But if yourdashboard is taking 10 minutes, DM me.Also if you'd like to read the full article, you can check it out here