I'm running a Drupal commerce site and using Views to display up to 30 product node teasers per page. The product display content type has a several fields (image, desc, manufacturer) and I am also using the flag module so that users can mark favorite products. As a result, the query ends up being fairly large with several joins.

Views statistics reveal that despite the complex query, the slow page loads are due to the rendering time it takes...

Query build time    21.13 ms
Query execute time  1.67 ms
View render time    4237.2 ms

How do I improve my Drupal template/rendering performance to get my pages to load faster?

  • Are your views being cached, and are you using MEMCACHE or some similar optimiser? May 28, 2012 at 19:15
  • No, views cannot be cached as each teaser rendered contains an add-to-cart form which doesn't work if cached. The HTML includes a form token specific to the original session / page view used to generate the HTML, it will be invalid once it's been cached.
    – nmc
    May 28, 2012 at 19:19

2 Answers 2


I would check for File IO; what does profiling your site tell you. I had similar issues and created the http://drupal.org/project/imageinfo_cache module and my views performance improved a lot by reducing file IO.

Seeing that your on shared hosing, checkout this http://kpayne.me/2012/02/04/use-register_tick_function-to-profile-your-code/

  • Thank @mikeytown2. I'm also on Drupal 7. Will check out the link.
    – nmc
    May 29, 2012 at 17:58

Here are a couple of the more obvious tips:

  1. Enable caching for your Drupal.

  2. Optimize your Drupal database. Log in to your Drupal admin area and go to Site Configuration > Performance. Besides enabling cache, you should also enable Page compression, Optimize CSS files and Optimize JavaScript files.

  3. If your Drupal is hosted on a dedicated solution, you can modify the global MySQL settings for better performance.

  4. *More for front-side micro-optimisation, you can check your website using this online tool. It will give you valuable information on what modifications can be made in order to improve its performance.

  5. Of course, disable/remove all modules/blocks you are not using.

Now, most of those are pretty basic and usual optimisations. I assume this is where you are now standing.

Next steps:

In my (humble) opinion, you would get way better response times if you install APC or Memcache on your server. There is also varnish I have heard lots of good things about, but I have not had the chance yet to play with it, and it looks like it is meant for anonymous sessions and static pages so I am not certain you would gain as much benefits than from other 2 above mentionned modules.

If you want to see benchmarks of a Drupal instance with/without APC caching, see here.

Last but not least, have you tried benchmarking without the flag module to see what impact this module has? We had to rewrite some queries of the like in other 3rd party modules a few times, some of the sql Drupal generates is not really optimised as you probably realised by now.

Happy coding, cheers!

  • Thanks for the well-written answer. This site is on a shared host unfortunately. So, I have no access to modify MySQL settings and cannot use APC on this particular host. A quick test of removing the flag module doesn't seem to have significant impact, but I'll have to do more thorough testing later.
    – nmc
    May 29, 2012 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.