title: Are there any advantages to using a custom _id for documents in MongoDB?
body: <p>Let's say I have a collection called <code>Articles</code>. If I were to insert a new document into that collection without providing a value for the <code>_id</code> field, MongoDB will generate one for me that is specific to the machine and the time of the operation (e.g. <code>sdf4sd89fds78hj</code>). </p>
  
  <p>However, I do have the ability to pass a value for MongoDB to use as the value of the <code>_id</code> key (e.g. <code>1</code>).</p>
  
  <p>My question is, are there any advantages to using my own custom <code>_id</code>s, or is it best to just let Mongo do its thing? In what scenarios would I need to assign a custom <code>_id</code>?</p>
  
  <p><strong>Update</strong></p>
  
  <p>For anyone else that may find this. The general idea (as I understand it) is that there's nothing wrong with assigning your own <code>_id</code>s, but it forces you to maintain unique values within your application layer, which is a PITA, and requires an extra query before every <code>insert</code> to make sure you don't accidentally duplicate a value.</p>
  
  <p>Sammaye provides an excellent answer here:
  <a href="https://stackoverflow.com/questions/14054384/is-it-bad-to-change-id-type-in-mongodb-to-integer/14058189#14058189">Is it bad to change _id type in MongoDB to integer?</a></p>