1. 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

Discussion in 'XenForo Questions and Support' started by RichardKYA, Feb 16, 2016.

  1. RichardKYA

    RichardKYA Well-Known Member

    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 :)
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    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.
     
  3. RichardKYA

    RichardKYA Well-Known Member

    Makes sense.

    It's just that on some pages, there's about 20 queries, then on others, there's 40+ queries, so I don't really know if that's fine or not?
     
  4. Brogan

    Brogan XenForo Moderator Staff Member

    That does sound a little on the high side.

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

    RichardKYA Well-Known Member

    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?
     
  6. Brogan

    Brogan XenForo Moderator Staff Member

    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.
     
  7. RichardKYA

    RichardKYA Well-Known Member

    Should I clear the caches and paste the info from the initial page load to get the highest reading?
     
  8. Brogan

    Brogan XenForo Moderator Staff Member

    Yes, you can do a before and after if you like.
     
  9. RichardKYA

    RichardKYA Well-Known Member

    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
    
     
  10. RichardKYA

    RichardKYA Well-Known Member

    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
     
  11. Brogan

    Brogan XenForo Moderator Staff Member

    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.
     
  12. RichardKYA

    RichardKYA Well-Known Member

    OK, I think I will do away with [bd] Widget and see how things go from there after that.

    Thank you for your help
     
  13. RichardKYA

    RichardKYA Well-Known Member

    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.
     
  14. Mouth

    Mouth Well-Known Member

    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
     

Share This Page