Our view is taking too long to render, can anyone offer suggestions to  
improve its speed?

There are 5830 profiles.

Total query count: 23809
Total duplicate query count: 493
Total SQL execution time: 66.003
Total Request execution time: 142.931

class Profile(Model):
     id = UUIDField(primary_key=True)
     user = ForeignKey(User, verbose_name=_('user'), unique=True,  
null=True)
     partner = ForeignKey('Partner')
     call_records = ManyToManyField('CallRecord', verbose_name=_('call  
record'), null=True, blank=True, help_text='Calls made by the user')

class Partner(Model):
     id = UUIDField(primary_key=True)
     name = CharField(max_length=255, help_text='The name for the  
partner')
     users = ManyToManyField(User, related_name='partner_users',  
null=True, blank=True, help_text='Users signed up specifically through  
this partner')
     providers = ManyToManyField('Provider',  
related_name='provider_partners', blank=True, null=True,  
help_text="Calling services owned by this provider.")
     calls = ManyToManyField('CallRecord',  
related_name='call_partners', blank=True, null=True, help_text='Calls  
made through this calling service.')

class CallRecord(Model):
     id = UUIDField(primary_key=True)
     provider_account = ForeignKey('ProviderAccount', null=True,  
blank=True, help_text='The calling service, if any, the call was made  
through')
     provider = ForeignKey('Provider', blank=True, null=True,  
help_text='The calling service the call was made through')

class Provider(Model):
     id = UUIDField(primary_key=True)
     name = CharField(max_length=255)

class ProviderAccount(Model):
     provider = ForeignKey('Provider', help_text='The calling service  
this account works with')
     username = TextField()
     encrypted_password = TextField(db_column='password')
     user = ForeignKey(User, help_text='The user this calling service  
account belongs to')


profiles =  
Profile 
.objects 
.filter(partner=request.partner,user__is_active=True).order_by('- 
user__date_joined')
for p in profiles:
       p.provider_list = list(
           account.provider for account in  
ProviderAccount 
.objects 
.filter(user=p.user,provider__provider_partners=request.partner))
       p.call_count = p.call_records.filter().count()
return PartnerResponse(request, {'profiles': profiles})

PartnerResponse returns the view to the user, the template uses a for  
loop to iterate through the profiles.



--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to