Make WordPress Core

Changeset 60717


Ignore:
Timestamp:
09/07/2025 08:33:43 PM (2 months ago)
Author:
SergeyBiryukov
Message:

Database: Add type_status_author index for the posts table.

This aims to improve performance of some queries on installations with a large number of posts.

Follow-up to [3678], [3690], [9290], [13576].

Props josephscott, LucasMS, Otto42, flixos90, matt, johnjamesjacoby, siliconforks, mukesh27, jonsurrell, SirLouen, SergeyBiryukov.
Fixes #50161.

Location:
trunk/src
Files:
3 edited

Legend:

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

    r60614 r60717  
    185185    KEY type_status_date (post_type,post_status,post_date,ID),
    186186    KEY post_parent (post_parent),
    187     KEY post_author (post_author)
     187    KEY post_author (post_author),
     188    KEY type_status_author (post_type,post_status,post_author)
    188189) $charset_collate;\n";
    189190
  • trunk/src/wp-admin/includes/upgrade.php

    r60716 r60717  
    24892489 * @since 6.9.0
    24902490 *
    2491  * @global int $wp_current_db_version The old (current) database version.
     2491 * @global int  $wp_current_db_version The old (current) database version.
     2492 * @global wpdb $wpdb                  WordPress database abstraction object.
    24922493 */
    24932494function upgrade_690() {
     
    25032504        $active_plugins[ $key ] = $new_plugin;
    25042505        update_option( 'active_plugins', $active_plugins );
     2506    }
     2507
     2508    if ( $wp_current_db_version < 60716 ) {
     2509        $wpdb->query( "ALTER TABLE $wpdb->posts ADD INDEX type_status_author (post_type,post_status,post_author)" );
    25052510    }
    25062511}
  • trunk/src/wp-includes/version.php

    r60497 r60717  
    2424 * @global int $wp_db_version
    2525 */
    26 $wp_db_version = 60497;
     26$wp_db_version = 60716;
    2727
    2828/**
Note: See TracChangeset for help on using the changeset viewer.