Uploaded image for project: 'Mender'
  1. Mender
  2. MEN-3290

[Research] Optimize mongodb _id indexes

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Open
    • Priority: Low
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
    • Days in progress:
      0

      Description

      All types of documents are at least indexed by their unique _id (UUID v4) field. In the current state these indexes are string type and uses the formatted, hex-encoded UUID values. That is, there are two sources of overhead in our current state: formatting the string UUID values and most importantly MongoDB string-type indexes are less efficient as the type can be variable sized. According to the documentation [1]:

      Index keys that are of the BinData type are more efficiently stored in the index if: (...) the length of the byte array is: 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, or 32.

      Moreover, [2] shows significant performance hit using the longer uuid compared to the 12-byte built-in objectID type. In go-terms this means replacing the string-type ID fields of all models with a fixed-size byte array and perform the necessary migrations.

      Acceptance criteria:

      • Research the performance impact of string vs binary type indexes
      • Decide which/whether collection uuid/objectID document models are worth migrating

      [1] https://docs.mongodb.com/manual/core/document/#the-id-field
      [2] https://github.com/Restuta/mongo.Guid-vs-ObjectId-performance
       

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              alfrunes Alf-Rune Siqveland
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:

                Summary Panel