11

I saw @parscale tweet: How many queries are you happy with for a home page? When do you say this is Optimized?

I saw responses that < 50 is good, 30 or less is best, and 100+ is danger zone. Is there really any proper number? And if say you do have > 50 queries running on your pages, what are some ways to bring it down?

I generally have sites that run the gamut that are under 50 queries and some more, though the "more" don't seem to be too slow, I'm always interested in making it faster. How?

lealea
  • 563
  • 2
  • 10

6 Answers6

11

How to reduce queries will vary from site to site, template to template, but there's been a few articles on EE optimisation and performance:

http://expressionengine.com/wiki/Reduce_Queries/
http://expressionengine.com/blog/entry/troubleshooting_site_performance_issues/
http://www.netmagazine.com/tutorials/optimise-your-expressionengine-site
http://www.leezilla.net/post/12377053779/ab-seeing-your-sites-performance
http://eeinsider.com/articles/using-cache-wisely-with-expressionengine/

But if you've done all that and still need to speed things up, then your next step is to look at add-ons like CE Cache.

Tyssen
  • 1,569
  • 16
  • 35
  • 1
    No I don't think so. My base install single entry page template with just text and no images and using SEO Lite and Stash uses 26 queries. That doesn't include navigation or listing of other entries or anything like that. – Tyssen Oct 24 '12 at 01:31
7

Thing to remember is not all queries are created equal. You can have 1,000 queries that do very little in the way of impacting performance, or a single query that can slow everything way down.

In EE its actually better to look at the template debug output and identify key slow down spots in the template build then to always focus on just the query count.

As others have pointed out products like CE Cache, Solspace's Template Morsels, or even adding a varnish caching server in-front of an intensive EE web site can do wonders, though with the added work required to fully get a varnish setup in front of EE setup, I would currently stick to the other solutions/directions first.

Nevin Lyne
  • 349
  • 1
  • 4
6

There is not a magic query number. In my opinion, your server environment dictates what can be supported. The more resources you have, the more complex your code can be.

With that said, there are lots of options you can use if issues do arise on an EE website. The links in the answer above give you a solid list but here are some first things to check:

  1. Remove search:field_name="" parameters
  2. Reduce use of channel tags, combine if you can
  3. Add disable="" parameter to channel tabs to disable what you don't need
  4. Reduce use of embeds
  5. Turn off all EE tracking code
  6. Stop using advanced conditionals if you have a channel tag inside
Anna_MediaGirl
  • 1,120
  • 13
  • 31
6

Following on from Nevin's point. I find that the JB Graphite is a huge help, it turns the debug output into a pretty graph, so you can easily spot bottleneck queries.

http://devot-ee.com/add-ons/jb-graphite

Geoff Cowan
  • 325
  • 1
  • 5
4

I'll expand on MediaGirl's point number 6 - you can often greatly simplify conditionals by using Croxton's Ifelse and/or Switchee add-ons. Definitely worth a look.

Jean St-Amand
  • 793
  • 5
  • 12
3

I used CE Cache on a really intensive build and it reduced page load from 6 seconds to 0.7 seconds. Awesome addpon, with incredible documentation and the best support you can get anywhere.

CreateSean
  • 1,286
  • 1
  • 21
  • 42