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

Make it possible to select a subset of documents based on the shard key

    • Type: Icon: New Feature New Feature
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Sharding
    • Labels:
      None

      I recently had to distribute a batch job among multiple workers; the way I finally did it was computing the xxhash over the _id and storing that in an extra field (_id_hash) as a Long.

      Using this field, I could distribute the documents from the collection among N workers by computing the _id_hash % N and then having worker zero using modulus 0, worker 1 using modulus 1 and so on.

      I figured that mongodb would use a similar approach internally to compute the db shard to store a document on; I tried to find a way to reuse that mechanism but could not.

      Would it be possible to expose that capability of the shard key somehow?

            Assignee:
            Unassigned Unassigned
            Reporter:
            karo Karolin Varner
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: