MyBB Community Forums

Full Version: Too many queries
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi. I'm new to MyBB and I was wondering why there are a lot of queries while simply watching a thread in my forum(SQL Queries: 19).

So I looked at "MyBB Debug Information", and I saw this:

SELECT * FROM MyBB_threads WHERE tid='1'

then after that this:

SELECT fid FROM MyBB_threads WHERE tid = '1' LIMIT 1

Didn't we gather the info in the first query? So why make a new one...

I have MyBB version 1.6.9.

Also this:

SELECT COUNT(*) AS replies FROM MyBB_posts p WHERE p.tid='1' AND (p.visible='0' OR p.visible='1')

It would be best to create a column for that in MyBB_threads table.

And you can add to MyBB_datacache table the information you take from:
SELECT name, tid, properties, stylesheets FROM MyBB_themes WHERE tid='3' LIMIT 1

Basically I want MyBB to make less queries so that the execution time will be shortened.

EDIT: Oh and one more suggestion is to be able to use templates via files instead of the database.
Like any other forum software. But to do that you would need to create database template to file template generator which would be kinda a bit difficult to make.
The reason for this is cause I heared somewhere in the past, don't remember where that the templates via files method is faster.

Thanks. I hope I didn't ask something newbie or whatever.
Some queries are ran by plugins, check the debug for that.

Also, while we don't store templates in the filesystem, they are cached; most of the templates are loaded by one query.
Thanks for the response.

Are you sure it's from a plugin? Cause I already disabled all of them.

And what you mean check the debug for that? Where is that place? Or you actually mean "MyBB Debug Information"?
(2013-02-11, 06:49 PM)Jabberwock Wrote: [ -> ]SELECT COUNT(*) AS replies FROM MyBB_posts p WHERE p.tid='1' AND (p.visible='0' OR p.visible='1')

That's probably a query only made for/my mods/admins.

(2013-02-11, 06:49 PM)Jabberwock Wrote: [ -> ]Basically I want MyBB to make less queries so that the execution time will be shortened.

You're going to have to get your hands dirty then. Wink

Do you have a huge forum? Because otherwise, it just doesn't matter whatsoever.
OK, managed to remove that query.

It was a query to override some theme selection I think. I'm surprised it isn't disabled since in my forum I only have 1 theme and I put it as default(Also forced on all users).

I only commented out with // after
$loadstyle = '';
$load_from_forum = 0;
$style = array();

until

if(empty($loadstyle))

It was in global.php.

oh and no it isn't a big forum.
(2013-02-11, 07:59 PM)frostschutz Wrote: [ -> ]
(2013-02-11, 06:49 PM)Jabberwock Wrote: [ -> ]SELECT COUNT(*) AS replies FROM MyBB_posts p WHERE p.tid='1' AND (p.visible='0' OR p.visible='1')

That's probably a query only made for/my mods/admins.

It is. It's there to check whether the unapproved post count is off.

We are looking to store some theme details, such as the default theme, in the cache in MyBB 1.8.