| Issue 26: | SQL optimizations | |
| 1 person starred this issue and may be notified of changes. | Back to list |
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.
Jun 6, 2008
#1
kir...@gmail.com
Jun 6, 2008
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
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. |