title: How to handle large data sets in MongoDB
body: <p>I need help in deciding which schema type is more appropriate for my mongodb collection.</p>
  
  <p>Let's say I want to store a list of things a person have. There will be relatively <strong>small number of people</strong>, but one person can have <strong>very many things</strong>. Let's assume people will be count in <strong>hundreds</strong>, but things a person own in <strong>hundreds of thousands</strong>.</p>
  
  <p>I can think of two options:</p>
  
  <p><strong>Option 1:</strong></p>
  
  <pre><code>    [{
          id: 1,
          name: "Tom",
          things: [
              {
                  name: 'red tie',
                  weight: 0.3,
                  value: 5
              },
              {
                  name: 'carpet',
                  weight: 15,
                  value: 700
              } //... and 300'000 other things 
          ]
      },
      {
          id: 2,
          name: "Rob",
          things: [
              {
                  name: 'can of olives',
                  weight: 0.4,
                  value: 2
              },
              {
                  name: 'Porsche',
                  weight: 1500,
                  value: 40000
              }// and 170'000 other things
          ]
      }//and 214 oher people]
  ]
  </code></pre>
  
  <p><strong>Option 2:</strong></p>
  
  <blockquote>
  <pre><code>[
      {
          name: 'red tie',
          weight: 0.3,
          value: 5,
          owner: {
              name: 'Tom',
              id: 1
          }
      },
      {
          name: 'carpet',
          weight: 15,
          value: 700,
          owner: {
              name: 'Tom',
              id: 1
          }
      },
      {
          name: 'can of olives',
          weight: 0.4,
          value: 2,
          owner: {
              name: 'Rob',
              id: 2
          }
      },
      {
          name: 'Porsche',
          weight: 1500,
          value: 40000,
          owner: {
              name: 'Rob',
              id: 2
          }
      }// and 20'000'000 other things
  ];
  </code></pre>
  </blockquote>
  
  <ol>
  <li>I will only ask for things <strong>from one owner in a single request</strong> and never ask for things from multiple owners.</li>
  <li>I will need a <strong>pagination</strong>  for the returned list of things so...</li>
  <li>... things will need to be <strong>sorted</strong> by one of the parameters</li>
  </ol>
  
  <p>From what I understand the first point suggest it would be much more efficient to use Option 1 (querying only few hundreds documents instead of millions), but points 2 and 3 are handled much more easily when using Option 2 (limit, skip and sort methods instead of $slice projection and Aggregation Framework).</p>
  
  <p>Can anybody tell me which way would be more suitable? Or maybe I've got something wrong and there's even better solution?</p>