title: Django: what is the need for len(queryset) after select_for_update(nowait=True)
body: <p>I am going through a block of legacy code (Python2.6 and Django1.3.3) to acquire lock. Backend is Oracle.</p>
  
  <p>Refer quoted block of code. What is the need for len(query set) on line number 8? I am particularly puzzled due to comment in line number 7. This particular line is consuming time in iterating through large number of records in query set. I am trying to know the reason to have this line before removing it.</p>
  
  <p>I will test this code and update here. I will try without this line and also try replace len with .count() method.</p>
  
  <pre><code>lock_acquired = False
  while not lock_acquired:
      try:
          where_clause= "is_deleted=0"
          avail_emp = Employee.objects.select_for_update(nowait=True).extra(where=[where_clause])
          log.debug("Acquiring lock")
          # *****Please dont remove below log to handle multiple requests at a time while rows are locked by a request*****
          log.debug(len(avail_emp))
          lock_acquired = True
          log.debug("Lock acquired")
      except Exception, e:
          log.debug("%s - Waiting for 2 secs before retry " %str(e))
          sleep(2)
  </code></pre>