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

Add an option to the $sample stage to specify weights to use in the sampling.

    • Query Optimization
    • Fully Compatible

      Specifying this option would prevent any optimized random cursor implementation from the storage engine, and would always use a top-k random sort, with the random value used to sort being multiplied by the specified weight.

      For example:

      db.example.aggregate([{
          $sample: {
              size: 100,
              weight: "$myWeightField"
          }
      }]);
      

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            m3t4lukas Lukas Wagner
            Votes:
            1 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated: