So far, there are three options. Looking for the most efficient in terms of performance

  1. A collection that stores all messages from all conversations. Records of the form:

    { conv_id: 5; msg: "example"}

  2. The collection with the name - dialogue id, containing messages only from its own dialogue.

  3. Collection with dialogs like:

     { conv_id: 5, #Ид диалога messages: [ { msg: "msg1" }, { msg: "msg2" } ] } 

    (Not suitable due to 16MB limit)

  • one
    First option. The third is perpendicular to the performance, the second will score a database for you so that you cannot navigate it. - etki
  • @Etki, thanks for the reply. I wonder why the third option is slower than the third? Does MongoDB work slowly with nested arrays? And also - if you use the first option - do you need to index the conv_id field? - rewardealer
  • one
    I’ll put in my 5 cents from: You need to index, and as I have already been through this, I recommend to compile a dialogue id from interlocutors id - Buka

0