title: Composite _ID and using MongoDB as a composite bucket store, via C#
body: <p>I am building an eCommerce system that uses composite bucket hashing to efficiently group similar items. Without going into why I chose this system, suffice it to say it solves several key problems facing distributed eCommerce system.</p>
  
  <p>There are 11 buckets, all of them ints, which represent various values. Let's call these fields A to K. The 12th field, L,  is an array of product IDs. Think of this all as a hierarchy with the leaf level (L) being data.</p>
  
  <p>I ran some initial tests in MongoDB where I stored this data as individual documents. However, this is not efficient because a given set of A to K could have many L values, so these can be stored as an array.</p>
  
  <p>This gives me two options:</p>
  
  <ol>
  <li>Insert a meaningless _id document id, and put an index on A - K to ensure uniqueness. I already ran some tests on indexes, and indexing more that the first 2 columns impacts speed substantially.</li>
  <li>Make A - K a composite _id, and have one document data field: L.</li>
  </ol>
  
  <p>I know #2 is a highly unconventional use of MongoDB. Are there any technical reasons why I shouldn't do this? If not, using the official C# driver, how would I perform this insert?</p>