Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Store employee info in mongo DB for entire country(considering more than 50 millions records)

I’ve to store employee(considering 50 millions records for future) data for each company(let’s say more than 1000 companies) what approach I should follow.

#1- Should I use single collection for user’s info?

#2- Should I use multiple collection on the basis of states of country(I’m thinking to create separate collection for each state of the country) to store user’s info.(so I will ask first state from user then Email & password during login). is it good approach.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Or any other optimised approach.

>Solution :

In my experience, the best way is to use a single collection with well-defined document structures and indexes for efficient storage and retrieval of employee data across multiple companies.

Using a single collection allows for easier management, scalability, and querying of data. You can include fields like company ID or state in each document to differentiate between companies or states.


Note:
By using indexes efficiently and structuring your documents appropriately, you can optimize performance without the need for separate collections. This approach simplifies data retrieval and ensures better performance as the dataset grows. Additionally, consider sharding for horizontal scaling if needed in the future.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading