• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.5 Database queries

RichardKYA

Well-known member
#1
I don't have much of an idea about MySQL and database queries, etc, so having a look in debug mode doesn't mean a lot to me, I understand, the fewer queries, the better things will be, but I have no idea how many queries are "good" and what would be considered "bad".

So, I guess my question would be, how many queries is "good" and how many is "bad"? Not expecting exact numbers here, just ballpark

Thank you :)
 

Brogan

XenForo moderator
Staff member
#2
The answer is it depends on the query.

Two or three smaller queries may in some cases be better than one big query.

In general though, the fewer queries the better.
 

Brogan

XenForo moderator
Staff member
#4
That does sound a little on the high side.

Which pages are they?
Is debug available for guests or just your IP?
 

RichardKYA

Well-known member
#5
Debug is not available for guests, my site is protected by aMember.

The pages vary, sometimes the home page is 41 queries, other times it's 29. Notable members 30-35. Forum view 25-30. Thread view 35-40. Being honest, the queries jump around a bit, so it's hard to keep any solid record of them.

As debug is not available to guests, I can PM you with admin access if you like?
 

Brogan

XenForo moderator
Staff member
#6
It's normal in some cases for the query count to be higher when first loading the page, as subsequent reloads may be accessing cached data.

Feel free to PM the details, or alternatively, you can just paste the query output here in code tags.
 

RichardKYA

Well-known member
#9
Here's a few of the pages...

First load

Code:
Timing: 0.3101 seconds
Memory: 6.888 MB
DB Queries: 41
Reload

Code:
Timing: 0.2389 seconds
Memory: 6.659 MB
DB Queries: 30

First load

Code:
Timing: 0.1938 seconds
Memory: 6.361 MB
DB Queries: 33
Reload

Code:
Timing: 0.1552 seconds
Memory: 6.090 MB
DB Queries: 25

First load

Code:
Timing: 0.6309 seconds
Memory: 6.606 MB
DB Queries: 37
Reload

Code:
Timing: 0.1916 seconds
Memory: 6.450 MB
DB Queries: 34

First load

Code:
Timing: 0.2528 seconds
Memory: 5.989 MB
DB Queries: 37
Reload

Code:
Timing: 0.1218 seconds
Memory: 5.634 MB
DB Queries: 20

First load

Code:
Timing: 0.1661 seconds
Memory: 6.383 MB
DB Queries: 36
Reload

Code:
Timing: 0.1187 seconds
Memory: 5.926 MB
DB Queries: 19
 

RichardKYA

Well-known member
#10
OK, I've been having bit of a play around, turning different add-ons off and on, not 100% sure, but I think the issue comes from [bd] Widget Framework, far as I can tell it appears to add about 10-20 queries. I'll have more of a play around tomorrow. Even with it turned off though, is 15-25 queries normal or is that still pretty high? What sort of range "should" they be between? Just so I can get a better gauge of things?

Thank you
 

Brogan

XenForo moderator
Staff member
#11
A default XF install with XFRM and XFMG should be 14 queries on the forum index (13 without XFRM and XFMG).

Anything more than that is due to add-ons.
 

RichardKYA

Well-known member
#13
Well, I got rid of [bd] Widget Framework and it pretty much cut my DB queries in half (y)

15-20 less queries per page. I only used the Framework for Latest Posts and Profile Posts too, so I'm surprised how many queries that it actually added.
 

Mouth

Well-known member
#14
Well, I got rid of [bd] Widget Framework and it pretty much cut my DB queries in half (y)
15-20 less queries per page. I only used the Framework for Latest Posts and Profile Posts too, so I'm surprised how many queries that it actually added.
Yeah, I don't use widget framework for that reason also (too many queries, too much load)
I do hope that XF 2.0 provides for a configurable sidebar across *all* XF pages though