• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

445
Views
In MongoDB, what is the purpose of embedded documents if the same thing can be achieved without using them?

For example

Instead of a field named, COLUMN_1, that holds an embedded document with fields A, B, and C.

Why not 3 separate fields with names COLUMN_1_A, COLUMN_1_B, COLUMN_1_C.

about 3 years ago · Santiago Trujillo
1 answers
Answer question

0

In mongoDB you prefer to work with documents the way they exist naturaly , afcourse you can create routines that can translate every time and assemble/disasemble the document:

  COLUMN_1:{A:X,B:Y,C:Z}

to:

 COLUMN_1_A:X,COLUMN_1_B:Y,COLUMN_1_C:Z

But this is additonal work that you dont want to do every time , you are a lazy effective developer that prefer just store your json document the way it will be used unless there is a specific use case that make sence to do it this way ... :)

Also please, note embedding is possible up to 100 levels , but max document size is still limited to 16MB , so in your document model it is not expected that you embed all your database in single document...

When you need performance , you add indices and optimize queries , that way your most searched data stay in memory , there is no big difference if your fields are embeded or in the root if they are not indexed ...

about 3 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error