Improving Site Performance

24 views
Skip to first unread message

Swaroop Shankar V

unread,
Apr 5, 2012, 3:41:46 AM4/5/12
to django...@googlegroups.com
Hi All,
Am developing a site using django and it is almost ready to be launched. Right now am trying to optimize the performance of the site. I have installed the django debug toolbar and when i checked the number of queries being exicuted on the homepage i could see there are 74 queries being executed. On debugging I could see that most of the queries  are through the context_instance=RequestContext(request) that am passing to a view. When I removed it I could see the queries where reduced to 24, which improved the performance, but I end up in an error 
Caught KeyError while rendering: 'request'
this is happening because the homepage is rendering a custom template tag which requires the request object available (to access the currently logged in user details). So is there any way to avoid using context_instance=RequestContext(request) and still make the request object accessible in the custom template tag?
Thanks and Regards,
Swaroop Shankar V

Phang Mulianto

unread,
Apr 7, 2012, 6:34:25 AM4/7/12
to django...@googlegroups.com
Well.. i think the lazy query is on action.

The query executed to get the data from database to be use in your view, if you said requestContext(..)

if you remove it, of course the data will not available in your view/template.

To reduce the query executed everytime you call the page, try use query caching..
one quick way without change code is use some cache like johnny-cache..it will automaticly cache your query and unvalidate it if your data changes.

i used it to.. and try load your page more than once, you will see in the debug toolbar, the query is reduced in the second and next load...that is the cache in action..

hope help..

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

Swaroop Shankar V

unread,
Apr 9, 2012, 5:20:02 AM4/9/12
to django...@googlegroups.com
Thanks Phang, I have not yet checked into the query caching in django. Will check and will see if it would improve the performance. Thanks a lot for your reply :)

Thanks and Regards,
Swaroop Shankar V



Reply all
Reply to author
Forward
0 new messages