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

Add allowDiskUse option to createView

    XMLWordPrintable

Details

    • Query

    Description

      In the mongo aggregation framework is possible to use the option

      {allowDiskUse:true}

      . This is really useful when some heavy operations such as sorting, which cannot be performed in memory.

      I'm trying to do the same with createView (available in Mongo 3.4), but it seems that this possibility is currently unavailable. For instance,

      db.mydb.aggregate([....,{$sort:{"a":-1}}],{allowDiskUse:true})
      

      works, but:

      db.createView("newview","mydb",[....,{$sort:{"a":-1}}],{allowDiskUse:true})
      

      produces the error

      The field 'allowDiskUse' is not a valid collection option.
      

      Of course, I can just remove

      {allowDiskUse:true}

      . Then the view is created, but when I try:

      > db.newview.find()
      Error: error: {
          "ok" : 0,
          "errmsg" : "Sort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting. Aborting operation. Pass allowDiskUse:true to opt in.",
          "code" : 16819,
          "codeName" : "Location16819"
      }
      

      Thus I would suggest to add the option allowDiskUse to createView.

      Attachments

        Issue Links

          Activity

            People

              backlog-server-query Backlog - Query Team (Inactive)
              RafaelCaballero Rafael Caballero [X]
              Votes:
              2 Vote for this issue
              Watchers:
              16 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: