Hello everyone,

I've noticed that when I look at the queries output of my app, I'm 
getting a LOT of repeating queries and a lot of queries that aren't 
needed at all. For example, I have a list of users, ordered by a certain 
property and paginated:

qs = User.objects.select_related().filter(...).order_by(...)

Now I have a 2 big problems:

1. get_profile( ) always queries the DB -for each user!-, even if I do 
the extra() or select_related() to get the profile table in there. 
(select ... from app_profile)

2. in the profile I'm generating some data, for example, the user's 
avatar filename will use self.user.username to create the avatars path, 
which will do yet another query (select ... from auth_user)!

Any ideas or hints as to how to avoid all these queries would be highly 
appreciated. On a page where I display 24 users, I'm getting 53 queries 
being fired, which is quite... excessive!


  - bram

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to