News for hackers. Stuff that matters.
Re:Why You Should Never Use MongoDB by dbcfd on Monday November 11, 2013 @04:02PM (#6714012)
db.find({"field":"value"},{"field":1,"someotherfield":2})

Finds all documents with field having value, returning only field and someotherfield. That part is similar to the map portion of a CouchDB/Couchbase view. No reduce portion though.

If field is what the index is built off of, it should be similar performance wise to a view. Just like views have to be created beforehand, so do mongo indices.

The difference is the find of a mongo document will happen much more quickly after insertion than the find of a couch value by view. Views require rebuild in couch which is not instantaneous.

Re:Why You Should Never Use MongoDB by m_mueller on Monday November 11, 2013 @04:24PM (#6714154)
If I understand couch correctly, it will run all map/reduce functions on a DB after insertion, thus updating all views right away - except if a view has never been queried, in which case it would happen at the first query. I don't quite understand how mongo could do a better job there - do you mean because mongo's indices are less complex than couch views, so the updates after insertion are quicker? I guess if that's the case it would perform better in insertion heavy cases, but then again I could just not use many map/reduce operations in couch and thus reduce the insertion overhead.
Re:Why You Should Never Use MongoDB by Lazare on Monday November 11, 2013 @05:10PM (#6714431)
Almost right!

For various complicated reasons, CouchDB update views on read, not on write. So you write some data, then you query a view, CouchDB notices the view is stale, recalculated everything, and then gives you the updated data. That can be a problem if your view is quite heavy because every time you write, the next read will be slow.

However! You can query with "stale=ok" (which means "just give me the old data, and don't kick off a view update"), and then update your views manually (eg, cron job that hits your view every so many minutes, or if you want to be smarter, a very lightweight daemon that monitors the _changes feed and hits your view every X updates, or whenever some key document is touched, or whatever).

Re:Why You Should Never Use MongoDB by dbcfd on Monday November 11, 2013 @04:50PM (#6714310)
From my tests with couch, the view isn't populated immediately after a document has been inserted, and may take some time. I think I tried this doing insert bulk, wait for view, insert 1, query, but I'd have to double check.
Re:Why You Should Never Use MongoDB by m_mueller on Monday November 11, 2013 @05:15PM (#6714461)
You and Lazare are right, I just checked the documentation and Couch indeed updates on first view query after a write.
Re:Why You Should Never Use MongoDB by gadamc on Monday November 11, 2013 @11:05PM (#6715779)
Cloudant (based on CouchDB) automatically triggers map-reduce and auto-compacts your database for you. This is my second post about Cloudant - note that I am employed by Cloudant. :)
Re:Why You Should Never Use MongoDB by dbcfd on Tuesday November 12, 2013 @08:06AM (#6717519)
Make it a product, and I'd be more interested. A number of companies have their own hosting, so the hosting part is not only unneeded, but is also usually a non starter.