title: MongoDB - Different collection per tenant
body: <p>We have a multi-tenant application and plan to store a significant amount of data in MongoDB.  For now, the plan is to have the same document schema across all tenants.  I’m new to Mongo, but I had a thought that it might make sense to store each tenant in it’s own sub-collection. For example database.collection.sub-collection would be:</p>
  
  <ul>
  <li>mydb.archivedata.123456</li>
  <li>mydb.archivedata.123457</li>
  <li>mydb.archivedata.123458</li>
  </ul>
  
  <p>Here is what I think the pros and cons will be:</p>
  
  <p>Pros:</p>
  
  <ul>
  <li>It would be faster since the indexes would be smaller</li>
  <li>When looking through the data through something like Robo 3T, it would be easier to find documents.</li>
  <li>Easier to delete a tenant.  Just delete their collection.</li>
  </ul>
  
  <p>Cons:</p>
  
  <ul>
  <li>When doing something like support, it would be very hard to query across collections.  e.g. Find me all the tenants that have this type of data.  It sounds like this be a fairly complex if not impossible join to write.</li>
  <li>Whenever I want to make changes to the index, I would have to apply it to every collection</li>
  </ul>
  
  <p>Should I even consider this?  Should I just stick with a single collection for all my tenants?</p>