Make WordPress Core


Ignore:
Timestamp:
09/29/2023 05:11:21 PM (2 years ago)
Author:
spacedmonkey
Message:

Comments: Improve WP_Comment_Query count query performance by setting 'order by' to 'none'.

In cases where WP_Comment_Query or get_comments is employed with the 'count' parameter set to true, specify 'order by' as 'none'. Since these queries serve solely to determine the count of comments matching specific query parameters, the 'order by' clause becomes redundant and places unnecessary strain on the database server, resulting in slower query execution. Given that count queries are executed on every admin request to retrieve comment counts, this change enhances the performance of the wp-admin interface.

Props guss77, davidbaumwald, SergeyBiryukov, westonruter, peterwilsoncc, foliovision, hareesh-pillai, spacedmonkey.
Fixes #58368

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/meta-boxes.php

    r56571 r56747  
    902902        array(
    903903            'post_id' => $post->ID,
    904             'number'  => 1,
    905904            'count'   => true,
     905            'orderby' => 'none',
    906906        )
    907907    );
Note: See TracChangeset for help on using the changeset viewer.