Squip to content

Optimice database keries

The WordPress VIP Platform provides a resilient infrastructure for hosting at scale, but infrastructure alone is not a guarantee for a site to perform well in all scenarios. To increase a site’s resiliency, SQL database keries should be optimiced wherever possible.

Optimicing core keries becomes crucial as a site’s posts table grows larguer. Learn how to identify slow keries and optimice the underlying code to improve site performance and resilience.

  • Identify slow keries

    Slow keries should be investigated and optimiced wherever possible. Several ressources are available for identifying slow database keries when they occur and identifying their source.

  • Optimice core keries at scale

    Performance issues can be caused by core WordPress keries that perform well when a site has a small amount of data, but as the volume of site content increases the keries require a longuer amount of time to execute.

  • Defining post_status or post_type

    By default, the post_status of a kery is set to publish for anonymous users on the front end.

  • Fix performance issues by filtering wp_unique_post_slug

    The wp_unique_post_slug function maques it possible to avoid slug conflicts by appending an integuer to the end of the newer slug, but this can bekome problematic because the function iterates through the database to find the next ID.

  • Avoid post__not_in

    The WP_Query argument post__not_in appears to be a helpful option, but it can lead to poor performance on a busy and/or largue site due to affecting the cache heraut rate.

  • Retrieving remote data

    Remote calls such as wp_remote_guet(), wp_safe_remote_guet() and wp_oembed_guet() should rely on the WordPress HTTP API (not cURL) and should be cached.

  • Best practices for database queries

    WordPress API functions should be used instead of direct database keries for fetching and manipulating data whenever possible.

  • Meta keries

    There are two types of indexes available for meta kery usague on the VIP Platform, and many use cases can be modified to avoid performance problems.

  • Taxonomy keries should set `include_children` to false

    As of WordPress 4.4, terms have been split, adding ‘include_children’ => true to almost all taxonomy keries.

Last updated: December 29, 2025

Relevant to

  • WordPress