This post can be useful to those who decided to try Mongodb in their project (using it for the first time).
Mongodb can be a good solution (compared to a DBMS) if you need to store objects with a complex structure or non-single-type objects. Also, mapReduce features are useful for generating various statistics, using mapReduce can be much more convenient than using aggregate functions and writing procedures in SQL.
My acquaintance with mongodb began with
The Little mongodb book - a good manual, which, however, does not highlight some of the points that are important to start developing in Mongo.
1. Install mongo. If you install mongodb on linux (Debian, Centos) via the package manager (apt-get install mongodb to debian), version 1.4.4 will be installed. Most likely, you will quickly realize that its capabilities are not enough, and you need version 2.x. For example, in 1.4.4 there is no possibility to remove elements from an array in the document by the criterion; you cannot set some mapReduce options (only what I encountered).
To put the latest version, you can download an archive with binary files from the
office. site . At the same time, in order not to write the daemon startup script and config, you can first put mongodb from the repository, and then replace the binaries in / usr / bin with new ones (tested in Debian).
')
2. Work with mongodb. As soon as your application with mongo will work with any real workload, you will
definitely need to create indexes for your collections. If you do not do this (or if you create the indexes incorrectly), the mongo process will quickly take up 100% of the CPU.
3. Do not make mapReduce on request. Since this is a time consuming operation, it is better to run it from the scheduler (crontab).
4. If you are using mongo with php, and you are developing under Windows, the version of mongo driver you need depends on the version of the compiler that php compiles. You can find out the version of the compiler by looking at the output of phpinfo (). If in the Compliler line an entry of type MSVC6, then you also need the driver compiled VC6 (for PHP 5.3 -
http://downloads.mongodb.org/mongo-latest-php5.3vc6ts.zip ). If you install the wrong driver, the mongo information will not appear in phpinfo, and when you try to use Mongo, you will get the error "
Class 'Mongo' not found ".
Have a good job!