title: mongodb: another "how to add a random record" thread
body: <p><strong>I've come across many of this same question here on StackOverflow. None providing a valid solid solution, so here we go:</strong></p>
  
  <p>I need to pick a random document from around 5 million documents in my MongoDB database in an efficient way.</p>
  
  <p>I've tried getting the <code>.count</code> and using the <code>.skip</code> to get the random document, but it takes almost three seconds and very, very inefficient.</p>
  
  <p>I can't make changes to the documents (like adding a "random") entry to each document or changing their _id's.</p>
  
  <p>I've tried the solution of adding documents with an incremental _id (to pick a random <code>_id</code> to bypass using <code>.skip</code>) but this brought more headache than what it did when I try to add many documents in a short amount of time.</p>
  
  <p>Adding data in an incremental way, or picking a random document, should not be this hard. I'm either missing some common knowledge, or doing something wrong, or this is what it really is..</p>
  
  <p>Wanted to bring up the topic and get your responses.</p>