vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   Forumdisplay Optimization (https://vborg.vbsupport.ru/showthread.php?t=4143)

10-25-2000 04:27 PM

Forumdisplay Optimization for vB 1.1.2 & 1.1.3 by rangersfan 2000

Open forumdisplay.php, and dont put in the dashes! As always backup forumdisplay.php in case something goes wrong.

Code:

Find this Code:
---------------
$threads=$DB_site->query("SELECT threadid,title,open,lastpost,replycount,postusername,lastposter,notes,iconid,views FROM thread WHERE forumid=$forumid AND visible=1 $datecut ORDER BY lastpost DESC LIMIT $limitlower,$perpage");
---------------

(editor note.. If you have changed this query and it no longer matches the above, the important part is to replace "iconid" with "thread.iconid", add "icon.title AS icontitle",
  add "icon.iconpath", replace "title" with "thread.title AS threadtitle" and add "LEFT JOIN icon ON (icon.iconid = thread.iconid)" after "FROM thread")

Replace with:
---------------
$threads=$DB_site->query("SELECT thread.iconid, icon.title AS icontitle, icon.iconpath,threadid,thread.title AS threadtitle,
                                open,lastpost,replycount,postusername,lastposter,notes,views,userindex
                          FROM thread
                          LEFT JOIN icon ON (icon.iconid = thread.iconid)
                          WHERE forumid=$forumid AND visible=1 $datecut
                          ORDER BY lastpost
                          DESC LIMIT $limitlower,$perpage");
----------------

Find this code:
----------------
  if ($showicons==1 and $thread[iconid]!=0) {
    if ($icon=$DB_site->query_first("SELECT title,iconpath FROM icon WHERE iconid=$thread[iconid]")) {
      $threadicon="<img src=\"$icon[iconpath]\" alt=\"$icon[title]\" border=0>";
    } else {
      $threadicon="&nbsp;";
    }
  } else {
    $threadicon="&nbsp;";
  }
----------------

Replace with:
----------------
  $threadicon="&nbsp;";
  if ($showicons==1 and $thread[iconid]!=0)
  {
    $threadicon="<img src=\"$thread[iconpath]\" alt=\"$thread[icontitle]\" border=0>";
  }
-----------------

version 1.1.2 and version 1.1.3beta1 and 2 Find this code:
-----------------
  if ($wordwrap!=0) {
    $thread[title]=eregi_replace("([^\n\r <>\"\\-]{$wordwrap})"," \\1 ",$thread[title]);
  }
  $threadtitle=htmlspecialchars($thread[title]);
-----------------

Replace with:
-----------------
  if ($wordwrap!=0) {
    $thread[threadtitle]=eregi_replace("([^\n\r <>\"\\-]{$wordwrap})"," \\1 ",$thread[threadtitle]);
  }
  $threadtitle=htmlspecialchars($thread[threadtitle]);
-----------------

version 1.1.3beta3 find this code:
-----------------
  if ($wordwrap!=0) {
    $thread[title]=dowordwrap($thread[title]);
  }
  $threadtitle=htmlspecialchars($thread[title]);

Replace with:
-----------------
  if ($wordwrap!=0) {
    $thread[title]=dowordwrap($thread[threadtitle]);
  }
  $threadtitle=htmlspecialchars($thread[threadtitle]);

That's it! Enjoy. This will cut your queries on forumdisplay from (Num of threads on page + 6) to 6!

Also please forgive me but I have a thing about code structure and readability.

[Edited by rangersfan on 10-26-2000 at 04:43 PM]

10-25-2000 04:37 PM

Quote:

Originally posted by rangersfan
Also please forgive me but I have a thing about code structure and readability.
Forgive you? I think *all* queries should be structured exactly like you've done... it makes it sooo much easier to read and maintain the code that way.

Wonderful optimization by the way, I am sure this will be a very nice performance increase :)

-Chris

10-25-2000 11:20 PM

Its amazing how this could slip the cracks. I would at least have thought they would have used a caching system, or maybe one query of all icons before loading the page.

People, this hack will increase performance (if mysql is your bottleneck, as it is in my case) greatly. Get it now. :)

10-26-2000 12:10 AM

Quote:

Originally posted by Stallion
Its amazing how this could slip the cracks. I would at least have thought they would have used a caching system, or maybe one query of all icons before loading the page.

People, this hack will increase performance (if mysql is your bottleneck, as it is in my case) greatly. Get it now. :)

hmmmm... mysql is my problem from day one... would these instructions change if i had hacks already ?

10-26-2000 12:12 AM

I dont' think there are any hacks (outside of my dot hack or VirtueTech's forum display sorting) that would have changed this code.

10-26-2000 12:26 AM

thanks i tried it on my long forgotten private testing vB which has the poll hack added also... seems to work.. gonna add it to my forums once i finish defragging my other pc with my working copy of my site files :)

10-26-2000 02:47 AM

great stuff rangersfan :) with me lowering my join buffers and adding this optimisation i survived my first forum peak hour without needing to reboot my server :D

10-26-2000 12:46 PM

Quote:

Find this code:
-----------------
if ($wordwrap!=0) {
$thread[title]=eregi_replace("([^\n\r <>\"\\-]{$wordwrap})"," \\1 ",$thread[title]);
}
$threadtitle=htmlspecialchars($thread[title]);
-----------------

Replace with:
-----------------
if ($wordwrap!=0) {
$thread[threadtitle]=eregi_replace("([^\n\r <>\"\\-]{$wordwrap})"," \\1 ",$thread[threadtitle]);
}
$threadtitle=htmlspecialchars($thread[threadtitle]);
-----------------
[/code]

Hi,

I have looked thru all files and cannot find the above statement. I have vb 1.1.3 too.

10-26-2000 02:17 PM

I will try this out after the major update!

10-26-2000 02:24 PM

Quote:

Hi,

I have looked thru all files and cannot find the above statement. I have vb 1.1.3 too.

Can you find the instances of $wordwrap in forumdisplay.php? You can also send me your forumdisplay.php and I will see what you are missing.

webmaster@hedgehogwheels.com


All times are GMT. The time now is 06:50 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.02098 seconds
  • Memory Usage 1,747KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete