Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > General > Member Archives

Reply
 
Thread Tools
Details »»

Version: , by (Guest)
Developer Last Online: Jan 1970 Show Printable Version Email this Page

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.

Comments
  #12  
Old 08-29-2000, 01:29 PM
Guest
 
Posts: n/a
Default

Quote:
Originally posted by Stallion
rangersfan: I don't have guest posting enabled on my forum,
so I wasn't aware of that problem. I'll look more into the
way vB handles non-registered posts and see if I can come
up with an update.
Actually this is more of a SQL syntax thing, you need to do
a left outer join between the post and user table, this way
all posts (within the criteria of course) will be returned
even when there is no user record available (as for guests).


Something like:
Code:
SELECT <fields> FROM post LEFT JOIN user ON (user.userid = post.userid) WHERE post.threadid=$threadid AND visible=1 ORDER BY dateline $postorder LIMIT $limitlower,$perpage
This is untested, but something along this line should work.

-Chris

[edit for readability]

[Edited by Chris Schreiber on 08-29-2000 at 10:32 AM]
Reply With Quote
  #13  
Old 08-30-2000, 03:34 AM
Guest
 
Posts: n/a
Default

Chris I changed it to what you posted and it seems to work

http://www.thebangles.net/forums/sho...hp?threadid=13
Reply With Quote
  #14  
Old 08-30-2000, 03:40 AM
Guest
 
Posts: n/a
Default

Wow! I am glad it worked... I know that dummy "0" user works too, I was just concerned it might mess something else up (having records with 'magic' key values like that sometimes cause problems).

-Chris
Reply With Quote
  #15  
Old 08-30-2000, 03:45 AM
Guest
 
Posts: n/a
Default

Yes it messed things up by forcing the key to 0
Reply With Quote
  #16  
Old 08-30-2000, 04:00 PM
Guest
 
Posts: n/a
Default

WOW.

I made the mods, then the corollary mods. An incredible improvement.
Reply With Quote
  #17  
Old 08-30-2000, 05:08 PM
Guest
 
Posts: n/a
Default

OK. I'm a bit confused. I made the original mods by Stallion (less the avatar piece) and it seemed to work fine. Does the subsequent piece by Chris work correctly? That '0' dummy piece left me wondering...
Reply With Quote
  #18  
Old 08-30-2000, 05:51 PM
Guest
 
Posts: n/a
Default

Yes I've been told it works just fine, and fixes the problem
if you allow your guests to post anonymously.

From the orignial where it says
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");
Change that to:
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 LEFT JOIN user ON (user.userid = post.userid) WHERE post.threadid=$threadid AND visible=1 ORDER BY dateline $postorder LIMIT $limitlower,$perpage");
And you should be good to go

-Chris


[Edited by Chris Schreiber on 08-30-2000 at 02:53 PM]
Reply With Quote
  #19  
Old 08-30-2000, 11:13 PM
Guest
 
Posts: n/a
Default

where would you add the to the above optimised code, rangersfan's avatar for iconpath ? and ed's location, interest hack for the biography field ?

in my existing showthread.php i have

Code:
$userinfo=$DB_site->query_first("SELECT userid,email,username,usertitle,signature,showemail,homepage,icq,aim,yahoo,joindate,posts,iconpath,biography FROM user WHERE userid=$userid");
with the added iconpath and biography

what do i change it to or add ? do i just add iconpath, biography to the end of it or something like user.iconpath as iconpath, user.biography as biography ?
Reply With Quote
  #20  
Old 08-30-2000, 11:26 PM
Guest
 
Posts: n/a
Default

Quote:
Originally posted by eva2000
.... something like user.iconpath as iconpath, user.biography as biography
Adding that to the list of fields should do it.

-Chris
Reply With Quote
  #21  
Old 08-30-2000, 11:42 PM
Guest
 
Posts: n/a
Default

Quote:
Originally posted by Chris Schreiber
Quote:
Originally posted by eva2000
.... something like user.iconpath as iconpath, user.biography as biography
Adding that to the list of fields should do it. -Chris
yep it worked my avatar, location/interest addons are still with me ...so far so good... but being on cable i can't really tell ...

[Edited by eva2000 on 08-30-2000 at 08:45 PM]
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:59 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04261 seconds
  • Memory Usage 2,284KB
  • Queries Executed 27 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (10)bbcode_code
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete