Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-12224

Allow an explicit padding (or total size) to be specified when inserting new documents

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: MMAPv1, Storage
    • Labels:
      None

      Description

      While the automatic padding factor is a good first-order approximation for determining data growth, it's not adequate for some stores in which the application can know in advance how large a document might grow to and in which growth has serious performance implications.

      In this case, MongoDB suggests adding manual padding.

      It would be nice if MongoDB supported this explicit padding naturally as part of the insert query. The insert (and probably upsert and save) operations would be extended with a 'padding_bytes' and/or a 'min_allocation_bytes' parameter (or similar) such that the insert operation would allocate a minimum amount of space for that document. For example::

      # ensure the doc is saved with a total allocation no less than 512 bytes
      db.my_items.insert({foo: "bar"}, {padding_bytes: 512})

      It appears that currently the insert operation doesn't accept any optional parameters, so this change would require extending that signature or otherwise providing such a mechanism.

      The advantages of this technique over the prescribed technique are clear:

      1) Only one round trip to save the document.
      2) Dummy data doesn't need to be constructed nor transmitted.
      3) If 'min_allocation_bytes' is used, the total allocation is explicit rather than dependent on the size of the essential document.
      4) The clients' usage is much simpler.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              backlog-server-execution Backlog - Storage Execution Team
              Reporter:
              jason.coombs@yougov.com Jason R. Coombs
              Participants:
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: