Fields marked with an * are required
I would like to ..
My WordPress ..

WordPress-Database-Optimization

We discuss a useful tool – Query Monitor – that helps with debugging slow WordPress database queries. 

Why Query Optimization?

WordPress is usually very efficient at executing its internal database queries. So generally speaking, you shouldn’t have to work on optimizing them. Most of the time when a page is slow, the culprits lie elsewhere. You can check our article on using Google’s Tools to debug performance issues. The typical contributors to poor performance are large images, render blocking Javascript, not lazy loading images, not minifying Javascript and such. For some practical guidelines on optimizing images, you can check our guidelines

We recommend investigating WP Query optimization only if you feel you have optimized all of the above items as much as you can. Another good reason to look into it is if your site has a lot of dynamic data and you have created a lot of custom post types to support it. For some useful pointers on how to do dynamic data design in WP, you can check out article

Query Monitor Features

Alright, with all those caveats, let’s jump in. A great place to start is the Query Monitor tool. You can download it here. The plugin lets you analyze much more than DB query times.

Query Monitor

Database Query Optimization

A great place to start is the Query Tab. 

shows all database queries executed along with the corresponding execution time. We can filter queries by query type (SELECT, UPDATE, DELETE) as well as the calling components.  Each query is monitored, timed, and tied back to the function that generated it. As a result, you can sort queries based on how long they take to process and pinpoint problematic, slow-loading queries.

Another useful feature is that you can check for any redundant queries in the Duplicate Queries tab: 

Filtering queries by component or calling functions makes it easy to see which plugins, themes, or functions on your site are making the most (or the slowest) database queries.

Finally, you should also check out the Transient Updates tab for any ineffective caching. Transients are a way of caching data for a predefined time in WordPress. Unlike storing data in the object cache, Transient API allows developers to store information in your WordPress database with an expiration time. 

The Transient Updates section shows any transients that were set, along with their timeout, component, and call stack. In summary, Query Monitor is a wonderful tool to optimize WordPress database queries. While there are more advanced Application Performance Management (APM) products such as New Relic and Firebase, we feel this is a great place to start.
Share on facebook
Facebook
Share on google
Google+
Share on twitter
Twitter
Share on linkedin
LinkedIn
Share on pinterest
Pinterest
Vinod Pabba

Vinod Pabba

Vinod is the Founder and CEO of Exemplifi. He is a graduate of Stanford University’s Engineering program and a successful entrepreneur having built and exited businesses in the past. He started Exemplifi with a singular focus on building websites that deliver to the complex marketing and technology needs of mid- and large- sized enterprises. He has built a team that understands the latest in web standards, has breadth and depth in several enterprise class CMS products, and can build dynamic websites that respond to user personas and various stages of the customer journeys. Vinod has two decades of digital transformation experience and has led several large site builds for enterprises globally. He is adept at delivering in an agile, multi-disciplinary and globally distributed manner.
You can reach us at nina@exemplifi.io or call us at 617-233-7510