WYSIWYG

http://kufli.blogspot.com
http://github.com/karthik20522

Tuesday, February 14, 2012

Mongodb - not so common basics

Basics of MongoDB:

* _id field is automatically indexed by MongoDB

* Maximum document size is 16MB

* Maximum size of a index field value is 800 bytes i.e. if a value who’s size/length is greater than 800bytes long, would be skipped from indexing. As an FYI, in SQL it’s 900 bytes.

* Searching against a non-indexed field is a no-no. This would be extremely slow and would require mongo to load all documents in memory to search. Note that MongoDB is fast as it tries to load maximum amount of data into memory.

* For a MongoDB to use Index the search key must be in order of text / beginning char of the index key

* A substring search of a Indexed field would not use the index. So a regex operation would be slow, since index’s wouldn’t be used.

* Index searches are case sensitive. Doing {/[value]/i} – non-case sensitive search would be slow

*MongoDB uses paged memory mapped.

*MongoDB creates index’s in background. Adding a new index’s though might take long (depending on size of collection) but also doesn’t cause Mongo to choke much. Be brave while adding new Index’s

* Use Explain command to get a quick overview of the query processing. Example:





* Remove one array item from a property, in one specific document:


- Remove all instances of a property, which happens to be an array, from all documents:


* MongoDB has a rest interface to monitor it’s status. It’s usually on 28017 port. - - rest is the command to enable rest interface.

* mongod is basically Mongo Daemon.

*MongoCSharp uses connection polling when using MongoServer.Create(). Do not programmatically disconnect the server as the open connection would be reused.

* When using MongoCursor, cursor.Count() can be used to get the total results when using limit and filter commands.

* For Windows users, MongoVUE is a pretty decent tool for visual interface.

* MongoDB monitoring is needed as like every other database. MMS (mongo monitoring service) is a good starting point. MMS is a free online agent provided by 10gen (MongoDB parent company)

* For a more speedier real time metrics interface, MongoLive chrome plugin is a good start.

Labels: