View Full Version : How to lower 104 queries on frontpage?
Gutspiller
07-10-2003, 01:35 AM
<a href="http://www.theforumz.com/forumz/" target="_blank">http://www.theforumz.com/forumz/</a>
Can peeps take a look at that and tell me what couple of things I might be able to take out that may affect my load query? I think 104 is kinda high. especially when I hear people talk about 17 and 24.
I know some of the stuff I have going on at the bottom is perhaps part of my problem. Anybody know off hand how many queries the "Current World Time" hack adds?
Anything to help would be appreciated.
Thanks. :dead:
Hmm is it just me or i see a page stating 33 queries which seems alrite. :)
? Copyright 2001 - 2003 CuttingTheEdge.com
vBulletin. Copyright ?2000 - 2003, Jelsoft Enterprises Limited.
Page generated in 0.7567490 seconds (-159.10% PHP - 259.10% MySQL) with 33 queries.
33 is still high.
Make sure you avoid:
Using querys in while loop's
Not adding your custom displayed templates to the $templatesused car
Install both the forumhome optimize hacks.
Remove the forum mod query in index.php, sence youve removed the moderator colum anyway :alien:
Gutspiller
07-10-2003, 06:57 AM
Yesterday at 10:26 PM Anime-loo said this in Post #3 (https://vborg.vbsupport.ru/showthread.php?postid=416620#post416620)
Remove the forum mod query in index.php, sence youve removed the moderator colum anyway :alien:
Where would I find that and what exact parts would I remove, do you know? certain code I should look for?
Tigga
07-10-2003, 02:26 PM
Well as a guest on your forums, you'll only see around 30 queries. As a registered member though, it's closer to 100. One thing you can do is add the following templates to the template cache at the beginning of the file -authority_list, forumhome_quicksearch, forumhome_dropdownbit, forumhome_quote, forumhome_newforumthreads.
You also have a query that appears to be counting the number of threads since a certain time for every forum, which is adding about 50 queries to your page -
SELECT COUNT(threadid) AS total FROM thread WHERE dateline>1057849698 and forumid=XX
Add those templates to the template cache, find that query above & remove it, and the number of queries should be a fraction of what they are now. :)
SmEdD
07-10-2003, 10:36 PM
Today at 03:57 AM Gutspiller said this in Post #4 (https://vborg.vbsupport.ru/showthread.php?postid=416657#post416657)
Where would I find that and what exact parts would I remove, do you know? certain code I should look for?
There a hack out there to put moderators into cache. Look at the code you edit and just remove the code completely. It's called forum home optmization I belive.
Gutspiller
07-12-2003, 12:15 AM
Yesterday at 09:26 AM Tigga said this in Post #5 (https://vborg.vbsupport.ru/showthread.php?postid=416710#post416710)
Well as a guest on your forums, you'll only see around 30 queries. As a registered member though, it's closer to 100. One thing you can do is add the following templates to the template cache at the beginning of the file -authority_list, forumhome_quicksearch, forumhome_dropdownbit, forumhome_quote, forumhome_newforumthreads.
You also have a query that appears to be counting the number of threads since a certain time for every forum, which is adding about 50 queries to your page -
SELECT COUNT(threadid) AS total FROM thread WHERE dateline>1057849698 and forumid=XX
Add those templates to the template cache, find that query above & remove it, and the number of queries should be a fraction of what they are now. :)
How do I had those things you said to the template cache? :confused:
Erwin
07-12-2003, 01:33 AM
In index.php, look for
$templatesused='
And add templates you are calling that are not cached into that line.
Gutspiller
07-12-2003, 02:52 AM
I added those others into the cache thingy and it took it down to a whole 98. :(
What are you saying I should do with the "SELECT COUNT(threadid) AS total FROM thread WHERE dateline>1057849698 and forumid=XX"? Or are you just saying that's the line that's causing the 50 or so queries? Where'd you find that? and if it is slowing down the page a lot, I will remove it?
Gutspiller
07-12-2003, 03:36 AM
UPDATE: WOW! I notice a huge improvement in the time it takes to load my forum frontpage. What about the mod column? I removed the code, but somebody was saying that the coding was still inside the index file. Can somebody help me out on where the code begins and ends that I need to remove? I looked at that optimzing the frontpage hack the filburt way and I couldn't find where I was suppose to find the code to take out.
I had another question for you guys. My frontpage news page loads really slow, is it possible to do any of this same type of caching so that it loads up faster too? the page that I'm talking about is this one: http://www.3dNewz.com It's the same site as http://www.TheForumz.com. Can anybody help me with that? :(
Tigga
07-12-2003, 08:02 AM
Try searching for something like this in your index.php file:
SELECT COUNT(threadid) AS total FROM thread WHERE dateline>
That's the query that's being executed 50+ times. If you remove that then it should lower the number quite a bit.
Skyline_GT
07-12-2003, 09:08 AM
wa i see this
Page generated in 0.3105130 seconds (-5,883.75% PHP - 5,983.75% MySQL) with 29 queries.
Gutspiller
07-12-2003, 09:10 AM
Today at 03:02 AM Tigga said this in Post #11 (https://vborg.vbsupport.ru/showthread.php?postid=417162#post417162)
Try searching for something like this in your index.php file:
SELECT COUNT(threadid) AS total FROM thread WHERE dateline>
That's the query that's being executed 50+ times. If you remove that then it should lower the number quite a bit.
Yeah I have this chunk of code in my index
f ((!$forumperms['canpostnew'] and $showlocks) or $forum['allowposting']==0) {
$forum['onoff'].='lock';
}
// prepare template vars
if (!$showforumdescription) {
$forum['description']='';
}
if ($bbuserinfo[userid]!=0) {
$newforumthreads = $DB_site->query_first("SELECT COUNT(threadid) AS total FROM thread WHERE dateline>$bbuserinfo[lastvisit] and forumid=$forum[forumid] ");
$newforumthreadvew = $newforumthreads[total];
eval("\$forum[newforumthreadvew] = \"".gettemplate('forumhome_newforumthreads')."\";");
}
How much of it do I remove?
Gutspiller
07-12-2003, 09:13 AM
Today at 04:08 AM Skyline_GT said this in Post #12 (https://vborg.vbsupport.ru/showthread.php?postid=417172#post417172)
wa i see this
Page generated in 0.3105130 seconds (-5,883.75% PHP - 5,983.75% MySQL) with 29 queries.
As we were talking above, guests don't see too many queries, but registered users see 98. We got a lot of stuff going on for registered users. :)
Tigga
07-12-2003, 04:59 PM
if ($bbuserinfo[userid]!=0) {
$newforumthreads = $DB_site->query_first("SELECT COUNT(threadid) AS total FROM thread WHERE dateline>$bbuserinfo[lastvisit] and forumid=$forum[forumid] ");
$newforumthreadvew = $newforumthreads[total];
eval("\$forum[newforumthreadvew] = \"".gettemplate('forumhome_newforumthreads')."\";");
}
You can remove that bit of code and it will take care of the offending query. It's apparently counting the number of new threads in each forum since a user's last visit, so you will lose that hack, but IMO a hack like that certainly isn't worth an additional 50 queries on your homepage. :)
By the way, it seems you may have installed the microstats hack wrong...
Page generated in 0.5169800 seconds (-506.86% PHP - 606.86% MySQL) with 92 queries.
The query count seems to be accurate, but obviously the percentages aren't. ;)
SmEdD
07-12-2003, 09:04 PM
Queries may be wrong if you think about it. Everything way oever what it's suppost to be.
Are you useing vB 2.3. If you are theres a fix for the microstats that you might not of used.
07-10-03 at 03:57 AM Gutspiller said this in Post #4 (https://vborg.vbsupport.ru/showthread.php?postid=416657#post416657)
Where would I find that and what exact parts would I remove, do you know? certain code I should look for?
in index.php
Find:
$forummoderators=$DB_site->query('SELECT user.userid,user.username,moderator.forumid
FROM moderator
LEFT JOIN user
ON (moderator.userid=user.userid)
ORDER BY user.username');
while ($moderator=$DB_site->fetch_array($forummoderators)) {
$imodcache["$moderator[forumid]"][] = $moderator;
$mod["$moderator[userid]"] = 1;
}
$DB_site->free_result($forummoderators);
unset($moderator);
Remove it.
Find:
// Start makeforumbit
function makeforumbit($forumid,$depth=1,$permissions='') {
global $DB_site,$bbuserinfo,$iforumcache,$ipermcache,$imo dcache,$session,$accesscache,$usergroupdef,$noperm s;
Change to:
// Start makeforumbit - modified
function makeforumbit($forumid,$depth=1,$permissions='') {
global $DB_site,$bbuserinfo,$iforumcache,$ipermcache,$ses sion,$accesscache,$usergroupdef,$noperms;
Find:
$listexploded=explode(",", $forum['parentlist']);
while ( list($mkey1,$mval1)=each($listexploded) ) {
if ( !isset($imodcache["$mval1"]) ) {
continue;
}
reset($imodcache["$mval1"]);
while ( list($mkey2,$moderator)=each($imodcache["$mval1"]) ) {
if ( !isset($forum['moderators']) ) {
eval("\$forum['moderators'] = \"".gettemplate('forumhome_moderator')."\";");
} else {
eval("\$forum['moderators'] .= \", ".gettemplate('forumhome_moderator')."\";");
}
}
}
if ( !isset($forum['moderators']) ) {
$forum['moderators'] = ' ';
}
Remove it.
Gutspiller
07-14-2003, 02:27 PM
Thanks.
Yeah, I've always had that problem with the microstats hack. I was never sure why it did it, but it was a small thing, I didn't care much about.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.