Version: 1.00, by Zzed
Developer Last Online: Feb 2012
Version: 2.2.x
Rating:
Released: 07-28-2003
Last Update: Never
Installs: 33
No support by the author.
This is a little hack that I did to improve the speed at which threads are
loading in my forums. I am experiencing very high server loads due to the
limited hardware on the server and due to the high post counts in my forums.
This hack has tremendously sped up showthread.php.
In order to view an entire thread, showthread.php makes 3 queries into the
post table. I have managed to divert one of these queries to the thread table,
and have managed to combine the remaining 2 queries into a single query.
The thread table is usually 10%-15% of the post table in terms of count, and
it is about 5% of the post table in terms of its physical size. Using the
thread table for one of the queries will definitely improve things.
This hack requires no template or table changes. It is just 3 simple code
changes made to the source code.
Show Your Support
This modification may not be copied, reproduced or published elsewhere without author's permission.
Today at 07:18 PM fury said this in Post #19 Why not just change this line...
Code:
$postids.= "post.threadid='$threadid'";
to this:
Code:
$postids.= "post.threadid='$threadid' AND post.visible='1'";
It might slow it down a tiny bit more but it works with moderated forums...
for moderated forums you'll need the other query ($postscount = $DB_site->query_first("SELECT COUNT(*)...) too, to get the right pagecount and page navigation.
this hack speeds thread-display because it will not have to crawl the whole post-table to check the "visible" column, it just uses the indexed "thread" column which is alot faster. this is not "a tiny bit" this is MUCH faster on big forums whith huge threads.
I've installed it on my 2 million post forum and it runs like a charm now.
Unfortunately I don't have a forum with 2 million posts to check it on. Why not index the visible column then? Since you have a multi-GB post table, what's an extra few dozen megs gonna hurt?
As for the post count, $thread['replycount'] is not incremented for posts that are placed in the moderation queue. it is only updated when they are taken out of the queue. That's the whole point of the reply count field, if there were more replies showing in the count on forumdisplay than were visible in the thread, people would start to wonder.
I like this hack and it definately improved the speed, but we have a moderated users hack and this causes those posts to show up anyway, so I had to uninstall it.
Today at 05:24 PM Alien said this in Post #25 fury's suggestion for reducing yet another query, has this been independently confirmed as well before I play with it.
I haven't tried it yet.. Waiting for confirmation, the same as you
These lines (that you ask me to replace) are different in my showthread.php:
PHP Code:
$postscount=$DB_site->query_first("SELECT COUNT(*) AS posts FROM post WHERE post.threadid='$threadid' AND post.visible=1$attachment_clause");
&
PHP Code:
$getpostids=$DB_site->query("
SELECT post.postid FROM post
WHERE post.threadid='$threadid' AND post.visible=1$attachment_clause ORDER BY dateline $postorder LIMIT ".($limitlower-1).",$perpage ");