MyBB Community Forums

Full Version: Very high "Query Time" ...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Salve!
I have changed my boardsoftware to MyBB (from phpBB) and now I am unhappy ... ^^
The MyBB is very slow and I cannot find the reason why. The server cannot be the problem.

An example, if I click on a subboard, the debug-mode shows me a very slow query:
SELECT tid,uid FROM mybb_posts WHERE uid='1' AND tid IN(1937,2259,3355,3496,3912,2679,3062,547,3392,2409,3880,
555,3131,3238,2986,3116,29,3309,3824,580,3296,4034,2601,3175,1869,1498,3978,3987,3970,3980)
table 	type 	possible_keys 	key 	key_len 	ref 	rows 	Extra
mybb_posts 	ALL 					461426 	Using where
Query Time: 1.2524681
What can I do?

Stephan

Edit: MyBB 1.1.7
Edit: Added a line break
The problem is an unoptimised DB query. With a DB that large, optimisation is very important. Also, I doubt if this query is the only one with such problems.

Try running these two commands in phpmyadmin or similar:
ALTER TABLE mybb_posts ADD INDEX `index_uid` (`uid`)
ALTER TABLE mybb_posts ADD INDEX `index_tid` (`tid`)
Salve!
Thank you!!! Smile
Before - Query Time: 1.2524681
After - Query Time: 0.0004799

For the moment the problem seems to be solved. Thx!

Stephan
Another way to save queries, if you apply your own mods that use extra .php files, is to always cache templates.

$templateslist = template1,template2,etc..;

I saved about 4 queries when I did this to one of my pages. Smile
Salve!
I have no own pages at the moment.
To post is slow, too. But I cannot find the reason why.

Stephan
That is interesting that the indexes weren't included in the 1.1.x installer (or 1.0 for that matter) because I do remember going through MyBB here and adding some.

The following should hopefully get you running fine (delete the previously posted indexes first):
ALTER TABLE mybb_posts ADD INDEX tid (tid,uid);
ALTER TABLE mybb_posts ADD INDEX uid (uid);
ALTER TABLE mybb_posts ADD INDEX dateline (dateline);
ALTER TABLE mybb_threads ADD INDEX fid (fid,visible,sticky);
ALTER TABLE mybb_threads ADD INDEX lastpost(lastpost,fid);
ALTER TABLE mybb_threads ADD INDEX firstpost (firstpost);
ALTER TABLE mybb_threads ADD INDEX uid (uid);
ALTER TABLE mybb_users ADD INDEX uername (username);
ALTER TABLE mybb_users ADD INDEX usergroup (usergroup);
ALTER TABLE mybb_users ADD INDEX birthday (birthday);
Salve!
Thanks for your help.
I have deleted the previously posted indices and used your indices but posting something isn't realy faster.

Stephan
"Speed" of your pages (ei, new posts) can also be greatly affected by your server on which you are hosted.

After moving to a new host I had noticed that my forums load much faster then they did on my previous host.
Debianer Wrote:Salve!
Thanks for your help.
I have deleted the previously posted indices and used your indices but posting something isn't realy faster.

Stephan
If you like, you can add <debugstuff> to the bottom of the redirect template anf it'll show you the debug stats for query time versus PHP which will give me a slightly better idea of where the bottle knecks are.

The reply speed etc is GREATLY improved in 1.2 because it does not need to worry about updating parent forums with the new post/thread counters and last post information.