Make WordPress Core

Changeset 16137


Ignore:
Timestamp:
11/01/2010 05:53:03 PM (14 years ago)
Author:
ryan
Message:

For large networks, show the latest registered blogs without paging to avoid expensive count queries. see #15170

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-ms-sites-list-table.php

    r16128 r16137  
    3232        $s = isset( $_REQUEST['s'] ) ? stripslashes( trim( $_REQUEST[ 's' ] ) ) : '';
    3333        $like_s = esc_sql( like_escape( $s ) );
     34
     35        $large_network = false;
     36        // If the network is large and a search is not being performed, show only the latest blogs with no paging in order
     37        // to avoid expensive count queries.
     38        if ( !$s && ( get_blog_count() >= 10000 ) ) {
     39            if ( !isset($_REQUEST['orderby']) )
     40                $_GET['orderby'] = $_REQUEST['orderby'] = 'registered';
     41            if ( !isset($_REQUEST['order']) )
     42                $_GET['order'] = $_REQUEST['order'] = 'DESC';
     43            $large_network = true;
     44        }
    3445
    3546        $query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' ";
     
    6475        $query .= $order;
    6576
    66         $total = $wpdb->get_var( str_replace( 'SELECT *', 'SELECT COUNT( blog_id )', $query ) );
     77        // Don't do an unbounded count on large networks
     78        if ( ! $large_network )
     79            $total = $wpdb->get_var( str_replace( 'SELECT *', 'SELECT COUNT( blog_id )', $query ) );
    6780
    6881        $query .= " LIMIT " . intval( ( $pagenum - 1 ) * $per_page ) . ", " . intval( $per_page );
    6982        $this->items = $wpdb->get_results( $query, ARRAY_A );
     83
     84        if ( $large_network )
     85            $total = count($this->items);
    7086
    7187        $this->set_pagination_args( array(
Note: See TracChangeset for help on using the changeset viewer.