I'm running a MongoDB service and some of the collections are data store only and I don't want let MongoDB loads these collections' data into memory. Is there any configuration for that?
MongoDB does not load the collection into memory, only the collection's indexes.
By default index is _id field only. You can't remove the _id index.
Related
We are doing migration from a collection(old collection) to another mongodb collection(new collection) in Azure cosmos. So while this migration we haven't created index in new collection and migrated all documents to new collection. So can we create index now in new collection or it should have created earlier before migration(before loading documents).Both(old & new collection) are sharded collection. Size of new collection is 211 gb, if I create index it will account for certain memory consumption(index size). So I would like to know is there any impact if we create index after loading documents? Are we good to create index after loading documents?
Yes, you can create indexes after the migration as well without any issues.
Please check this documentation for the commands to create various index types.
The commands to track progress of the indexing operation are also provided on the same document.
I am working on processing the mongodb oplog and I create a collection in mongodb to add the processed data and I don't want this collection to again generate oplog.
I want all other collection to generate oplog but need to exclude one of the collection. How can I achieve this. Is there any settings to let mongodb know not to generate oplog for a collection.
Any help is appreciated.
Collection in local database are not part of replication. So, If you create a collection in the local database and insert records to that, oplog entries are not created.
I want to perform a huge query that performs joins across my database, more than 600 collections with billions of documents. The point is that if I perform that query, my db will explode because MongoDB will be trying to load the index of each collection.
¿Is there any way to avoid MongoDB to automatically load the indexes of each collection?
I am using Elasticsearch along with MongoDB.
Mongo is my primary DB and Elasticsearch is used for search feature.
Mongo changes are synched to Elssticsearch using Mongo Oplog.
I have a case where I need to get a document by passing document id(i.e., Mongo '_id'). Which DB is efficient for this query, Mongo DB or Elasticsearch?
Thanks
If this Id is also your shard key in MongoDb then Mongo would be more efficient as it would know in which shard to look. Elasticsearch will search all of the shards and so be less efficient.
If MongoDb is your single source of truth and you have the Id then use Mongo. If you need full text search then use Elasticsearch.
I have a collection, like is:
{ name:aaa,
nick:bbbb,
item:[{item_id:123456,price:13.00},
{item_id:833457,price:12.00},
.....
}]
}
I had set the collection to sharding , the sharding key is name and item.item_id. If I had save many many items into collection.
I have a question:
If these data saved to one collection, not contain a embeded document, will lead to sharding. But I have save these data to embeded document(the example), can sharding or not sharding?
Thanks.