Hello,
I'm new to django, and set up a website recently, (puncut.com). I was hoping
someone might be able to explain how to optimise database calls because at
the moment some pages are taking 5 seconds before django responds.
I'll summarise the scenario below:
# models
class Thread(models.Model) :
... bunch of fields including title, description, author (linked to User)
class Pun(models.Model) :
thread = models.ForeignKey(Thread)
author = models.ForeignKey(User)
... other fields like content etc.
class Like(models.Model) :
liker = models.ForeignKey(User)
pun = models.ForeignKey(Pun)
So there are puns in threads, and users can like puns.
The view which lists latest threads is particularly slow. It sends threads
to the template, and the template loops through threads and inside it loops
through the puns which are in that thread. in pseudo code:
for thread in threads
for pun in thread.pun_set
output pun.content
But I reckon that makes way to many calls to the database. I think I ought
to use select_related , but I tried it and it didn't speed it up.
Thanks for any help,
Matt
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
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.