Version: , by (Guest)
Developer Last Online: Jan 1970
Version: Unknown
Rating:
Released: 08-29-2000
Last Update: Never
Installs: 0
No support by the author.
There had to be a way to speed this section of code
up, since it was the slowest loading page on my board.
After looking at how it was handled, I discovered that the
script executes a new mySQL query for every post displayed
on that page. This query is used to suck out relevant user-
specific information not stored in the post table (such as
username, post count, icq, etc.
So on a page with 30 posts, you'd have 30 resource-taking
SQL calls. Thanks to old-school UBB'er TDawg for helping me
realize that a join was the answer!
Any forum user should make this change, but especially
those who notice a bit of latency when viewing an
individual post. (the main factor of speed in this is the
size of your user database -- not the number of
posts/threads). So, here are the changes, which include one
hella-big SELECT statement...
Perhaps John will integrate this into the next version? Its
a real resource-saver, and doesn't have any negative side-
effects (yet )
Note: Please backup showthread.php before
performing this modification!
Look for:
Code:
$posts=$DB_site->query("SELECT dateline,postid,pagetext,allowsmilie,signature AS showsignature,title,ipaddress,iconid,username,userid FROM post WHERE threadid=$threadid AND visible=1 ORDER BY dateline $postorder LIMIT $limitlower,$perpage");
Replace with:
Code:
$posts=$DB_site->query("SELECT post.dateline as dateline,post.postid as postid,post.pagetext as pagetext,post.allowsmilie as allowsmilie,post.signature AS showsignature,post.title as title,post.ipaddress as ipaddress,post.iconid as iconid,post.username as fakename,post.userid as userid, user.userid as userid,user.email as email,user.username as username,user.usertitle as usertitle,user.signature as signature,user.showemail as showemail,user.homepage as homepage,user.icq as icq,user.aim as aim,user.yahoo as yahoo,user.joindate as joindate,user.posts as posts FROM post,user WHERE post.threadid=$threadid AND visible=1 AND user.userid = post.userid ORDER BY dateline $postorder LIMIT $limitlower,$perpage");
Look for:
Code:
$userinfo=$DB_site->query_first("SELECT userid,email,username,usertitle,signature,showemail,homepage,icq,aim,yahoo,joindate,posts FROM user WHERE userid=$userid");
Replace with:
Code:
$userinfo = $post;
Look for:
Code:
$username=htmlspecialchars($post[username]);
Replace with:
Code:
$username=htmlspecialchars($post[fakename]);
That's all -- let me know if you notice any speed improvements! :-)
[edit: adjusted for width]
[Edited by Stallion on 08-28-2000 at 10:49 PM]
Show Your Support
This modification may not be copied, reproduced or published elsewhere without author's permission.
$posts=$DB_site->query("SELECT post.dateline as dateline,post.postid as postid,post.pagetext as pagetext,post.allowsmilie as allowsmilie,post.signature AS showsignature,post.title as title,post.ipaddress as ipaddress,post.iconid as iconid,post.username as fakename,post.userid as userid, user.userid as userid,user.email as email,user.username as username,user.usertitle as usertitle,user.signature as signature,user.showemail as showemail,user.homepage as homepage,user.icq as icq,user.aim as aim,user.yahoo as yahoo,user.joindate as joindate,user.posts as posts,user.receivepm as receivepm FROM post,user WHERE post.threadid=$threadid AND visible=1 AND user.userid = post.userid ORDER BY dateline $postorder LIMIT $limitlower,$perpage");