Aggregation with multiple db

Hi, There i have a design for store my data in multiple object, with indexes between them.
My question is if there’s a way to aggregate between multiple db or not and it’s better to store all the data in one db to run aggregate more fast and easy?

1 Like

Hi @Ohad_Haviv,

Welcome to the Community :slight_smile:

Hi, There i have a design for store my data in multiple object, with indexes between them.

Would you be able to provide further context regarding your use case with examples?

My question is if there’s a way to aggregate between multiple db or not and it’s better to store all the data in one db to run aggregate more fast and easy?

You won’t be able to perform an aggregation that merges data from differing databases. There is the $lookup stage available which allows for merging of data between collections within the same database.

Deciding whether an object should live in a different collection, or embedded into another object in one collection is an important part of designing your application data model. There are few factors to consider before choosing a particular data model. I would recommend taking a look at the Building with Patterns blog post which highlights the pros and cons between different design patterns.

Hope this helps,
Jason

3 Likes

Thank you. Its not possible also if i store indexes in one db to another?

Hi @Ohad_Haviv,

Thank you. Its not possible also if i store indexes in one db to another?

Would you be able to provide some sample document(s) and expected aggregation results?

Indexes are defined at the collection level. You may find the following documentation regarding Databases and Collections useful.

Best Regards,
Jason

1 Like