MyBB Community Forums

Full Version: Lots of slow SQL queries
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
I am www.bhtuning.com administrator, reason I post here is that no one else can give me the right answer.
Site is hosted on hostmonster servers. MyBB is 3 years old (updated to 1.4.5 yesterday), I have changed many hosts, and my account was disabled yesterday on hostmonster for causing server unavailability.
I will post slow queries from today...

Figures on image are ... online users, total users, posts, threads.
[Image: pokitc928d86ff00aeb89a39bd4a80e652a38.png]

Thank You in advance!
The numbers seem quite high so you may need a dedicated host.
I get that a lot lately Smile
There are about 4000-5000 users a day, and ~ 400 every hour, I modded some of the .php files, but it is ussualy a block of code, for example....

if($tid=="3605")
{
		include_once("params.php");
		include_once("sanitize.php");
		$sta=sanitize_sql_string(param("sta"));
		if($sta!=""){
		$extra=file_get_contents('http://www.bhtuning.com/sm/index.php?sta='.$sta);
		}else{
		$extra=file_get_contents('http://www.bhtuning.com/sm/index.php');
		}
}

Shows catalogue script before posts on http://www.bhtuning.com/thread-3605.html ( $extra is a variable in template "showthread").

I need to make sure, that some of mods I have done on my own are not causing troubles.

I have also setup fresh installation of MyBB 1.4.5 on http://tuning.letargo.net, but I am unable to connect to database on hostmonster. I've done that to see performance difference.

Or, simply, I need a dedicated host? Thanks.
You can do a few things to minimize queries. One big problem is search. Have guests unable to search and make sure you have a minimum characters maybe like 5 to start with. Also remove features that take up a lot of sql that isn't needed.

I peeked at the logs. Looks to me like you just need a better host. Most of those queries shouldn't take that long.
Hi,

MyBB is well optimized. I personally help run a forum with 4 million posts and 20,000 members. If your forum is slow its because of modifications, plugins, or a slow server. You should look into a dedicated server if it is not plugins or modifications.

Thanks,
Ryan
It doesn't appear to be plugins or mods...check this:

# Query_time: 2 Lock_time: 0 Rows_sent: 0 Rows_examined: 0
SELECT title,cache FROM forum_datacache

2 seconds just to grab 2 columns from a small table. That should be .02 instead.
Thank You for replies.
Yesterday, forum was updated and it worked like a clock. Although hostmonster blames slow sql queries, I have looked server status now and it shows this...
Quote:2009-04-22 13:43:46: Box under heavy load -- you may experience degraded system performance

Please take look a the code...

//Tema Komentari
		
if($thread['fid']=="26"){
$link = mysql_connect('localhost', 'bhtuning', 'x');
mysql_select_db('bhtuning_x');

	$upit = "SELECT * FROM forum_threads WHERE fid='96' AND uid='".$thread['uid']."' LIMIT 1";
	$rezultat = mysql_query($upit);
	$rezultat = mysql_fetch_assoc($rezultat);

	if(empty($rezultat['tid']) == false)
	{
		$komentari="<center><a href='http://www.bhtuning.com/thread-".$rezultat["tid"]."-lastpost.html'><img src='images/ikone/komentari.png'></a></center>";
	}
}

I open another connection to db, does that increase SQL load significaly? This is "showthread.php", opened 70000 times a day, but fid 26 is not opened that much.
2009-04-22 13:43:46: Box under heavy load -- you may experience degraded system performance

That's a host problem.
You may also want to consider these: http://community.mybboard.net/thread-43165.html
Problem solved, never doubted MyBB, moved www.bhtuning.com to dedicated server Big Grin Everything works great!
HostMonster sucks Angry!
Keep up the good work Smile