0

I'm running MongoDB (2.2) on Linux, and I have a few questions.

I have schema with many fields + sub-fields and one index for this fields.

  1. How fast are updates/delete done on the index -- I have about 3 Updates/Deletes etc. a second.
  2. Is there a rule, like after 10,000 updates you have to compact or rebuild the index?
  3. Are changes in the fields immediately visible in the index? If not is there a delay or a temporary table for this updates/deletes?

Thanks in advance - Brandon

Jr0
  • 2,131
  • 13
  • 23
  • Yes, index is updated in sync with the data. There's no delay. – Sergio Tulentsev Jan 22 '13 at 18:43
  • Indexes are updated without delay but when you delete data in mongodb if you don't execute db.repair() command, released data won't be freed to the operating system be aware of that: http://api.mongodb.org/wiki/current/Excessive%20Disk%20Space.html – cubbuk Jan 22 '13 at 19:30
  • Indexes can be delayed if they are sent to background. released data will be sent to a $deletedlist of buckets each representing a possible size of the deleted document. When a new document is inserted or updated and it needs moving MongoDB will do a seek of around 30 (or something like that) of these buckets to judge if there is a good fit for the new size of a record. Using consistently growing documents can cause fragmentation with this method however you can use power of 2 sizes padding on your document to lower the risk of movement. – Sammaye Jan 22 '13 at 19:42

1 Answers1

0
  1. Indexes are updated at the time of insert/update/remove. About performance the best answer would be to just test it.
  2. Not that I would know of. If you need to do regular compaction or repair you should have replication too (but you can have it on the same host if resources permit)
  3. Yes (well, on the same DB connection - on other it might take a bit more time. But if you're having that problem I'm not the right person to answer you anyway ;)

Having said that, I strongly suggest you take a look at some of the presentations at http://www.10gen.com/presentations - I'm sorry i can't point out the ones that were particularly interesting and usable, I suggest you browse and pick the ones that seem interesting to you.

Note that MongoDB does things VERY differently and has quite a few gotchas for the unprepared. It is however a great DB once you know how to use it.

johndodo
  • 17,247
  • 15
  • 96
  • 113