My favorites | Sign in
Project Home Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 26: SQL optimizations
1 person starred this issue and may be notified of changes. Back to list
Status:  Accepted
Owner:  ----


 
Reported by kir...@gmail.com, Jun 6, 2008
I did some modifications that greatly reduce a number of sql queries. The 
number of queries no longer depends on the number of threads, posts or 
users. For instance only 1 query is used to fetch all the threads along 
with their latests posts and authors. Thanks to 'select_related' django's 
method which is just genious! :)

Unfortunately some of these changes break backward-compatibility, as I 
have added a new field 'latest_post' to 'forum' and 'thread' tables. So I 
don't know if you decide to merge it, but for me it's defenitely worth to 
have.
optimize.diff
8.3 KB   View   Download
Jun 6, 2008
#1 kir...@gmail.com
bwt, how to change a type of an issue here? As it is not a "Defect".
Jun 6, 2008
Project Member #2 rwpoul...@gmail.com
Hi Kirrax,

Thanks for the submission. I'll try and merge it into trunk over the weekend.

The reason we don't have a ForeignKey on Forum to the latest post, is that if that
latest post is deleted it will delete the forum! See Issue # 15
(https://code.google.com/p/django-forum/issues/detail?id=15&can=1) for more details.

I like the other changes you've made though, I'll add them to the codebase shortly.
Status: Accepted
Labels: -Type-Defect Type-Enhancement
Jun 7, 2008
#3 kir...@gmail.com
aha, I see. But this issue can be easily fixed by adding "self.thread = None" to 
Post.delete() function, right before the call to "super(Post, self).delete()"

There is no need to remove 'latest_post', as the 'latest_post' property of the 
thread also gets changed some line above in my patch.

0 bytes   Download

Powered by Google Project Hosting