ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

How many queries is too many?

January 17, 2011 11:45am

Subscribe [3]
  • #1 / Jan 17, 2011 11:45am

    Have you ever enabled the Output Profiler (Admin > System Administration > Output and Debugging) on one of your sites to see how many DB queries it takes to load a given page? I did it on one of my sites out of curiosity and was horrified by the results. Some of my simpler content pages were still taking between 30-40 queries to load, and the more complex listing pages with lots of conditional and embedded templates were into the 200s (especially the ones that are pulling data from Matrix fields). I was wondering if these numbers are comparable to yours if you’ve ever checked or if I’m doing something VERY wrong when I build sites. Any input would be hugely appreciated!

  • #2 / Jan 23, 2011 9:12pm

    Boyink!

    5011 posts

    You’re not doing anything wrong, you’ve just had the scales lifted from your eyes as to what EE is doing for you behind the scenes..😉

    So much of EE’s performance depends on the hosting environment that I don’t think there is an answer to your question, other than “when the page doesn’t load fast enough..😉

    Make sure to use the “disable” parameter as much as possible, take advantage of the different caching options, turn on gZip output, etc - but overall don’t worry about the number of queries until it affects performance.

  • #3 / Jan 24, 2011 10:57am

    handyman

    509 posts

    Have you ever enabled the Output Profiler (Admin > System Administration > Output and Debugging) on one of your sites to see how many DB queries it takes to load a given page? I did it on one of my sites out of curiosity and was horrified by the results. Some of my simpler content pages were still taking between 30-40 queries to load, and the more complex listing pages with lots of conditional and embedded templates were into the 200s (especially the ones that are pulling data from Matrix fields). I was wondering if these numbers are comparable to yours if you’ve ever checked or if I’m doing something VERY wrong when I build sites. Any input would be hugely appreciated!

    Many forum pages take 50+ queries, but I never saw 200…....
    My regular EE pages load much quicker than my forum pages, but I don’t use as many add-ons.

    It would seem that in a perfect world, each page would use as few queries as possible…..or at least the best queries!
    But with a one-size fits all (or most) solution like EE, this is impossible…..

    I’d prefer not to look in most cases…...look at the server load and see if you are above a comfortable level, and if so optimize, optimize and optimize some more….or step up in CPU and RAM…which greatly helps MySQL.

    I just checked a simple article page and it was about 40 queries, which include maybe 10 or more to add-ons.

  • #4 / Jan 24, 2011 11:06am

    Thanks for the input guys. It turns out that the page which had 200+ queries had some problems with a third-party fieldtype which I fixed and that brought it down to under 100. After caching and using the disable parameter wherever possible I brought the number of queries down to about 35, which I’m happy with after hearing from you guys and talking to some EE developer friends of mine.

    This may be a “it depends” type question, but what’s acceptable server load? My templates are using about 8MB of server memory.

  • #5 / Jan 24, 2011 12:06pm

    handyman

    509 posts

    Server load? It depends, of course….whether you have a dedicated, etc…..

    As a very general statement, if it is below double the amount of cores you have in the CPU you are usually in decent territory…..or, look at the CPU idle amount - if you regularly have the CPU idle at 0 to 15% (meaning they are mostly used), you might be close to hitting the wall.

    My dual core server was OK as long as server load was below about 4.
    My newer Xeon, with the same exact load (users and pages on it) is never going above 1 for any length of time. I suspect it is improvements in the threading and other stuff in the Xeon.
    That is a dedicated server with 4G Ram….nothing too special on the drives (most stuff serves from Ram, anyway).

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases