Profiling Slow Code Print

  • developersgitdeployment, developers, performance, plugins, database, caching, troubleshooting, wordpress
  • 0

Finding where time is actually spent.

MEASURE BEFORE OPTIMISING

Assumptions about what is slow are usually wrong. Measure first.

TOOLS

Query Monitor for WordPress shows database queries, their duration, and which plugin issued them Framework debug bars show similar information Server-side profilers give a detailed breakdown, where available Browser developer tools show what happens after the response arrives

WHAT TO LOOK FOR

The number of database queries per page. Hundreds indicates a problem, usually a query inside a loop. A single query taking a large share of the time, usually missing an index. A plugin or module consuming disproportionate time. External API calls made during page load, which make your page as slow as someone else's server.

THE COMMON FINDINGS

An unindexed query on a table that has grown A plugin doing work on every page load that it only needs to do occasionally A remote API call with no timeout or caching

FIXING

Cache expensive results Add indexes Move slow work to a scheduled task rather than a page load Remove the plugin


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot