View Full Version : Query load
Sia Bani
10-23-2002, 12:17 AM
Hi all. Newbie here. I just installed Teck's microstats and this is what I'm getting for my index data:
Page generated in 0.11948705 seconds (60.20% PHP - 39.80% MySQL) with 32 queries.
[Debug Mode OFF] [PHP v4.2.2] [GZIP disabled] [Server Load: 0.10 ยป 0.47 : 0.63]
Is 32 queries too high? I only have about 60 members now, my forum is about 2 weeks old. Will I run into trouble with more users?
thanks.
Erwin
10-23-2002, 12:35 AM
32 queries for index.php is not too bad. Considering an unhacked index.php gives only 17, 32 is almost doubled - so it depends on how busy your forums are going to get. How many members at one time? If overall you have 60 members, 32 is fine. :) The general rule is to get it at least below 30 if possible.
Sia Bani
10-23-2002, 12:37 AM
thanks for the quick response. I've installed several hacks that I really want to keep, so is there anyway to minimize the queries without getting rid of teh hacks?
Erwin
10-23-2002, 12:49 AM
Interesting drawing for a splash screen on your site. :) Like I was saying, there's no real need to reduce it with the number of members you've got now. You can rationalize the PM queries from 3 to 1 by replacing the current code in your index.php for PMs with this:
$allpm=$DB_site->query_first("SELECT COUNT(*) AS messages,
SUM(IF(dateline>$bbuserinfo[lastvisit] AND folderid=0,1,0)) AS newpm,
SUM(IF(messageread=0 AND folderid=0,1,0)) AS unreadpm
FROM privatemessage WHERE userid=$bbuserinfo[userid] $ignoreusers");
$newpm['messages']=$allpm['newpm'];
$unreadpm['messages']=$allpm['unreadpm'];
Also, if you don't need to know the number of threads in the forums, or the name of the newest member etc. - each one of those takes one query. Just remove the relevant lines in your index.php. Make sure all templates are listed in your templatesused ="" variable at the top, or else each template called is an extra query too.
Sia Bani
10-23-2002, 12:59 AM
Hey, thanks a lot.
Erwin
10-23-2002, 01:03 AM
No problems, glad to help. :)
Dean C
10-23-2002, 09:28 AM
Erwin that code however if i remember correctly can add more queries under certain circumstances..
- miSt
Erwin
10-23-2002, 11:59 AM
How? It's one query line. When you get a new PM, you get 2 extra queries, but that's not from this line of code, it's for the PM popup.
Xenon
10-23-2002, 02:02 PM
Erwin is right mist ;)
@Sia: you should look if you have a query in a while - loop through one of your hacks.
if yes, this is a don't do ;)
ask in the supportthread if this can be optimized then :)
Dean C
10-23-2002, 06:27 PM
Lol ill leave it to the advanced hackers ;)
I just had a hunch id seen that before and PPN said not to do it for some reason or another :)
- miSt
Xenon
10-23-2002, 09:34 PM
he hasn't said it exactly to this optimization.
he just says sometimes it would be better to have more queries instead of one real great query :)
it always depends on the situation
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.