Remove expensive operation in MongoDB?

Part of my site migration to MongoDB is messaging migration. I am trying to find out if I should actually delete the entries from the collection or mark them as deleted using some bool field, when the user wants to delete the message - the site will have a lot of load, so I am concerned about performance (and not about disk space).

Any ideas?

+6
source share
1 answer

tl; dr: remove.

MongoDB stores the data in a double linked list, so deleting the results corrects the two links, the next link of the previous document and the previous link of the next document. There is no auto-association. The update, if you have already saved the value, occurs in place, changing one value. Now ... you think fine, update one int instead of two pointers, of course, faster! Not so - you now need to index this flag, and index creation is slow.

+13
source

Source: https://habr.com/ru/post/888740/


All Articles