Re: Help optimising database calls

2011-01-12 Thread Matt Henderson
I managed to improve the speed of the site by using memcached to cache the rendered Thread views M On 12 January 2011 16:23, Matt Henderson wrote: > Thanks Lukasz and Matias, > I've implemented something along those lines in my view: > > threads = > list(Thread.objects.select_related('author').a

Re: Help optimising database calls

2011-01-12 Thread Matt Henderson
Thanks Lukasz and Matias, I've implemented something along those lines in my view: threads = list(Thread.objects.select_related('author').all().order_by('-created'))[:150] threads_map = {} for t in threads: threads_map[t.pk] = t t.pun_collection = [] for pun in Pun.objects.all().filt

Re: Help optimising database calls

2011-01-12 Thread Ɓukasz Rekucki
On 12 January 2011 16:32, Matt Henderson wrote: > 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

Re: Help optimising database calls

2011-01-12 Thread Matias Aguirre
Try to reduce the queries on your view, select_related won't help a lot if using Thread model, try to collect Pun values on your view first and group them by thread, itertools.groupby could be handy in this case. Try something like: threads = Thread.objects.select_related('user').filter(...) threa

Re: Help optimising database calls

2011-01-12 Thread Dan Fairs
> 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: [snip] > But I reckon t

Help optimising database calls

2011-01-12 Thread Matt Henderson
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)