title: Django slow performance on processing requests
body: <p>I have a django platform and I've found a strange slow performance when the server tries to response some http requests.</p>
  
  <p>I've managed to isolate a little useless code that shows a strange delay, from which all the others can be derived.</p>
  
  <p>case 1) If I have this function:</p>
  
  <pre><code>def get_n_events(request):
      a = request.user
      return HttpResponse("5")
  </code></pre>
  
  <p>the response is very fast, as expected:
  <a href="https://i.stack.imgur.com/FF6Xs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FF6Xs.png" alt="enter image description here"></a></p>
  
  <p>Only 12.61ms, very fast, as expected.</p>
  
  <p>case 2) But if I have this function:</p>
  
  <pre><code>def get_n_events(request):
      a = request.user.username
      return HttpResponse("5")
  </code></pre>
  
  <p>the response:
  <a href="https://i.stack.imgur.com/HpzM1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HpzM1.png" alt="enter image description here"></a></p>
  
  <p>it takes more than 2 seconds!</p>
  
  <p>How can be this delay explained and how can I avoid this huge time when I need to access the data inside the request? (For example, in my case I need to know the request.user.group_name, but it takes too much tome to get a response.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I made some tests with Django Debug Toolbar and I saw that the huge time 
  is not due to SQL runtime.
  <a href="https://i.stack.imgur.com/4KJBj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4KJBj.png" alt="enter image description here"></a></p>
  
  <p>As we can see, the SQL takes only 183ms, but the request has 1354msecs.
  Where does this time come from and how can I reduce it? </p>