title: random.sample on Django querysets: How will sampling on querysets affect performance?
body: <p>I was trying to sample a few records from my queryset for performance like:</p>
  
  <pre><code>from random import sample
  from my_app import MyModel
  
  
  my_models = MyModel.objects.all()
  
  # sample only a few of records for performance
  my_models_sample = sample(my_models, 5)
  
  for model in my_models_sample:
      model.some_expensive_calculation
  </code></pre>
  
  <p>But I felt like it made only worse in terms of execution time.</p>
  
  <p>How does <code>random.sample()</code> actually works behind the scene? And will it be rather performance burden on django querysets?</p>