Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 2.x > vBulletin 2.x Full Releases
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Thread view optimizations Details »»
Thread view optimizations
Version: 1.00, by Zzed Zzed is offline
Developer Last Online: Feb 2012 Show Printable Version Email this Page

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.

Comments
  #22  
Old 08-03-2003, 04:44 PM
pwr_sneak pwr_sneak is offline
 
Join Date: Oct 2001
Location: Germany
Posts: 19
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
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.
Reply With Quote
  #23  
Old 08-03-2003, 06:29 PM
fury's Avatar
fury fury is offline
 
Join Date: Oct 2001
Location: Indiana
Posts: 108
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #24  
Old 08-03-2003, 08:21 PM
cirisme cirisme is offline
 
Join Date: Jan 2003
Posts: 136
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.

Definately a great concept though
Reply With Quote
  #25  
Old 08-03-2003, 09:14 PM
romeshomey romeshomey is offline
 
Join Date: Oct 2002
Location: Ohio
Posts: 119
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nice.. Thanks
Reply With Quote
  #26  
Old 08-04-2003, 03:24 PM
Alien's Avatar
Alien Alien is offline
 
Join Date: Oct 2001
Posts: 827
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

fury's suggestion for reducing yet another query, has this been independently confirmed as well before I play with it.
Reply With Quote
  #27  
Old 08-04-2003, 05:47 PM
Oblivion Knight's Avatar
Oblivion Knight Oblivion Knight is offline
 
Join Date: May 2002
Location: Sheffield, UK
Posts: 1,757
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
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
Reply With Quote
  #28  
Old 08-04-2003, 11:54 PM
Alien's Avatar
Alien Alien is offline
 
Join Date: Oct 2001
Posts: 827
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can this optimization work with this hack below?

https://vborg.vbsupport.ru/showthrea...threadid=36416

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
"
); 
How would I make this compatible?
Reply With Quote
  #29  
Old 08-10-2003, 02:31 PM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

great hack, noticed it straight away
Reply With Quote
  #30  
Old 08-10-2003, 04:12 PM
Alien's Avatar
Alien Alien is offline
 
Join Date: Oct 2001
Posts: 827
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Any solution on my question above anyone?
Reply With Quote
  #31  
Old 08-13-2003, 04:17 PM
David Bott David Bott is offline
 
Join Date: Dec 2001
Posts: 215
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Mow installed on AVS Forum (http://www.avsforum.com) and it does help with this large active site.

Anything to make the DB server happier.
Reply With Quote
Reply


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 05:26 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06649 seconds
  • Memory Usage 2,311KB
  • Queries Executed 25 (?)
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
  • (2)bbcode_code
  • (2)bbcode_php
  • (2)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_onlinestatus
  • (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_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
  • postbit_imicons
  • 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