I have tried MongoMapper and it is feature complete (offering almost all AR functionality) but i was not very happy with the performance when using large datasets. Has anyone compared with Mongoid? Any performance gains ?
14 Answers
I have used MongoMapper for awhile but decided to migrate to MongoId. The reason is hidden issues plus arrogance towards users. I had to jump through hoops to make MongoMapper work with Cucumber (succeeded in the end) and to put a couple of patches even the project was simple, but it's not the point. When I tried to submit a bug fix (due to incompatibility with ActiveRecord), they seemingly got pissed off that I found a problem and I was pushed around. While I was testing, I also encountered a major bug with their query implementation, while their testing was tuned in a way that the tests pass. After my previous experience, didn't dare to submit it.
They have a significantly lower number of pull requests and bug/feature submissions than MongoId, i.e. community participation is much lower. Same experience as mine?
I don't know which one has more features right now, but I don't see much future in MongoMapper. I don't mind fixing issues and adding functionality myself, but I do mind situations when they wouldn't fix bugs.
-
Can I ask you, what was the major bug in the query implementation. I have used mongomapper in a previous project, but it was also my first exposure to mongo at all. Any information on specific issues with mongomapper you had would be great. Thanks – Red Jan 20 '12 at 04:43
-
5When getting first() without sorting, it works as last() instead (or visa versa). But the unit test is written in the way that it specifies order, so it passes. May be it's fixed by now, but I don't use MongoMapper anymore. But I doubt it, I saw how it was implemented, and it's a bad design. – Aynat Mar 01 '12 at 22:19
-
Hi, can you send link for info about how to smoothly migrate from mongo mapper to mongoid? – Chen Kinnrot Jul 06 '12 at 09:11
-
1@Aynat I dont thing it fixed yet I tried it gave me the same result – Viren Oct 22 '12 at 16:30
-
Thank God i saw this conversation was just deciding to use mongomapper or mongoid in my next big project. Guess Mongoid wins. – aliirz Aug 24 '13 at 13:57
-
We're thinking about migrating to Mongoid as well ... any suggestions? Did you run into any hurdles during the migration? – Crashalot Dec 30 '13 at 10:54
i've been using both for the past couple weeks. Mongomapper has better support for relational associations (non-embedded) and has greater third-party support. Mongoid has better query support, much better documentation (MM has close to none, though a website is supposedly in the works), Rail 3 support (and thus Devise support) and a slightly more active community on Google Groups.
I ended up going with Mongoid.

- 5,493
- 4
- 33
- 31
-
27Since I originally wrote this answer Mongoid has picked up lots of third-party support and the difference in the communities is even greater. In my opinion Mongoid is more of a clear choice today. Performance should be relatively the same as they both go through the Ruby driver. Though you need to be careful with OM not to construct horrendous documents. – Nader Feb 01 '11 at 00:53
-
MongoMapper's many-to-many is broken: https://github.com/jnunemaker/mongomapper/pull/259, https://github.com/jnunemaker/mongomapper/issues/488 +1 for Mongoid – Yevgeniy Jan 17 '13 at 23:44
Differences
MongoMapper
- Claimed to have better support for relational associations.
- Claimed to be more extensible because of it's plugin architecture.
- Uses a DSL for querying.
- Many-to-many associations are updated only one-sided in MongoMapper.
- Less robust support for embedded documents. Updates the entire model even if only a few attributes are modified.
Mongoid
- Suggested to be faster than MongoMapper by anecdotal evidence.
- More robust support for embedded documents, using MongoDB atomic operations ($set, $push, $pull, etc.) to update nested documents in-place.
- Supports bidirectional many-to-many associations.
- Uses a chainable ARel-like syntax for querying.
Similarities
- Both MongoMapper and Mongoid have websites with good documentation. MongoMapper was long claimed to have bad documentation, but their new website seems to close the gap.
- Both can be configured through a YAML file, and both have a rails generator for that file.
- Both are fully Rails 3 compatible.
Configuration
MongoMapper
defaults: &defaults
host: 127.0.0.1
port: 27017
development:
database: database_name
Mongoid
development:
sessions:
default:
database: database_name
hosts:
- 127.0.0.1:27017
3rd Party Libraries
Both sides have claimed to have better 3rd party support. Github reveals the following:
- Searching for "Mongoid" yields 12671 results.
- Searching for "MongoMapper" yields 4708 results.
Notably, Devise does not support MongoMapper.
Commit Activity
Over the last year, it looks like Mongoid has been more regularly maintained and updated than MongoMapper.
MongoMapper
Mongoid

- 6,699
- 8
- 48
- 80
A difference I found is that update_attribute
in MongoMapper appears to write the whole document, regardless of what attributes actually changed. In Mongoid it only writes the changed attributes. This can be a significant performance issue for large records. This is particularly true for embedded documents (here labels
), e.g.
profile = Profile.find(params[:id])
label = profile.labels.find_or_create_by(idx: params[:idx])
# MongoMapper doesn't have find_or_create_by for embedded docs
# -- you'll have to write custom code
profile.save
On save
, MongoMapper will save the whole profile
record, but MongoId will use the $set
operator with positional logic to only update the label that changed.
Another issue is selecting which fields to return. Both support an only
criterion, but Mongoid also supports a without
criterion, which is natively supported by Mongo.
It appears to me that Mongoid just is more "rounded" and complete in its API, which probably explains that it's a larger code base. It also appears documented better.

- 7,159
- 5
- 44
- 64
Did you install mongo_ext? I think the performance is more related to the driver than the mapper itself. When looking at the mongo log, I can see without the extension, that the transer seems to have some lags.
Also do as they recommend on the monogdb site, select only the fields you need.

- 1,030
- 1
- 10
- 19
-
ruby driver is not that fast especially 1.8 but 1.9 just boosts the performance! i am just wondering if mongoid is more optimized or the only thing it offers is a different approach to quering and stuff for the time being mongomapper is almost feature complete offering almost all AR sugar – PanosJee Dec 26 '09 at 11:25
-
1Note to those reading this over a year later: `mongo_ext` is no longer needed and has been rolled into the basic `mongo` gem. – tkrajcar Nov 14 '11 at 04:37
Did some testing with MongoMapper last week, it was stable but I found the query interface a little limited (also some of the AR logic was quirky), switched to Mongoid today and it feels much better to use - and more intuitive if you are used to AR.
No speed conclusions yet - but the switch over was painless - it works with Rails 3 too.

- 404
- 4
- 4
If you're using Rails3 I'd recommend Mongoid -- it also uses "include" instead of inheritance "<" to persist classes -- using "include" is the better paradigm in Ruby for adding persistence. Mongoid works fine for me with Devise.
To improve performance, try to selectively use the lower-level access, e.g. Moped - I've seen this to be up to 10x faster

- 33,354
- 5
- 79
- 106
I think Mongoid is much better at configuration and mapping.

- 7,895
- 15
- 63
- 84
-
1I think so too. Besides that it feels closer to NoSQL than MongoMapper that it makes you think more in terms of ActiveRecord and therefore SQL. Another plus is the great documentation – PanosJee Sep 13 '10 at 19:54
-
I used both of them and they are about to equals in functionality, but look at it's code stats
It looks like MongoMapper has much better code quality (if it does the same with less).
You can calculate this stats by Yourself, here's the analyzer https://github.com/alexeypetrushin/code_stats

- 13,598
- 11
- 69
- 133
-
12
-
10
-
Can you explain more please? Is this the same project using each of those libraries? Is it an average character count across all github projects? From looking at this chart, couldn't I argue that people are writing much more complex projects using MongoID than using MongoMapper? (just asking. I'm actually a MM user right now) – colllin Feb 19 '12 at 02:47
-
> Is this the same project using each of those libraries? It's a comparison of the size of source code of MongoMapper & Mongo. – Alex Craft Feb 22 '12 at 19:41
-
14Comparing the code quality of a project through code size is like comparing the quality of 2 cars by measuring the weight. – Patrizio Rullo Jun 02 '12 at 16:29
-
3Actually comparing weight of cars is perfectly valid - You can make a lots of judgment - how fast it is, how much it takes gasoline, and so on. And, actually it is makes sense from scientific point of view, take a look at "Kolmogorov complexity". – Alex Craft Jun 02 '12 at 19:53
-
1Still, altough some have greatly improved mongomapper's speed (https://www.coffeepowered.net/2013/07/29/mongomapper-performance-improvement/), it is still known and accepted that mongoid is faster. – Adit Saxena Aug 09 '13 at 08:05
-
Another thing regarding the comparison to the cars: they both use different engines so weighting just the car without the weight of their drivers (moped vs 10gen) doesn't mean a thing. Again, speed and how code is mantained (taken care): these are the only thing that matters i a project. – Adit Saxena Aug 09 '13 at 08:08
sudo gem install mongo_ext
is key to getting performance.
MongoDB blows away CouchDB in terms of raw speed – though CDB does have its own set of advantages.
Benchmark: http://www.snailinaturtleneck.com/blog/?p=74
-
He's talking about mongoid x mongo_mapper, what is the faster ruby gem to access mongo, not mongodb x couchdb. – Victor Rodrigues Mar 08 '10 at 14:53
-
8Note to those reading this over a year later: `mongo_ext` is no longer needed and has been rolled into the basic `mongo` gem. – tkrajcar Nov 14 '11 at 04:37
I hope Below points add values to above answers.
1.Mongoid is completely Rails 3 compatible, and uses ActiveModel all over the place (validations, serialization, etc), where MongoMapper is still focused on Rails 2 and uses the validatable gem for its validations.
2.Mongoid officially supports and works on Ruby 1.8.7, 1.9.1, and 1.9.2 head.
3.Mongoid supports embedded documents more robustly, performing the MongoDB atomic operations on any area of the hierarchy internally. ($set, $push, $pull, etc). With MM you need to explicitly tell it to do these operations.
4.MongoMapper has better relational association support and works like this as default.
5.MongoMapper is more extensible, with a plugin architecture that makes it pretty easy for people to extend it with their own libraries. Mongoid does not have this.
6.MM supports identity maps, Mongoid does not.
7.MM has a larger community, and probably more 3rd party library support. I went crazy on documentation and rdoc.
8.Mongoid supports Master/Slave replication clusters. (Writes to master, round robin reads to slaves) MM does not.
9.Mongoid has an extremely rich ARel style criteria API, MM use AR2 style finders.

- 8,298
- 4
- 36
- 49
I would expect performance to be the same, last time I checked MongoMapper lacked Rails 3 support - so I am looking at Mongoid for now.

- 8,963
- 3
- 33
- 35
Devise did not support MongoMapper, and I too prefer moving in the Rails3 way. So I switched to mongoid.

- 961
- 8
- 17
Mongoid is having a full support with Rails3 and having identity map feature.
More document is at http://mongoid.org
See the performance here http://mongoid.org/performance.html

- 1,193
- 6
- 8