Make WordPress Core


Ignore:
Timestamp:
11/19/2010 06:16:03 PM (14 years ago)
Author:
ryan
Message:

Site search performance tweaks. Use subquery for registration log queries to allow cross DB queries. Lose order by id by default. Search only by blog_id for numeric search strings. see #15170

File:
1 edited

Legend:

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

    r16438 r16489  
    5555        } elseif ( preg_match('/^[0-9]+\./', $s) ) {
    5656            // IP address
     57            $reg_blog_ids = $wpdb->get_col( "SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE ( '{$like_s}$wild' )" );
     58
     59            if ( !$reg_blog_ids )
     60                $reg_blog_ids = array( 0 );
     61
    5762            $query = "SELECT *
    58                 FROM {$wpdb->blogs}, {$wpdb->registration_log}
     63                FROM {$wpdb->blogs}
    5964                WHERE site_id = '{$wpdb->siteid}'
    60                 AND {$wpdb->blogs}.blog_id = {$wpdb->registration_log}.blog_id
    61                 AND {$wpdb->registration_log}.IP LIKE ( '{$like_s}$wild' )";
     65                AND {$wpdb->blogs}.blog_id IN (" . implode( ', ', $reg_blog_ids ) . ")";
    6266        } else {
    63             if ( is_subdomain_install() ) {
     67            if ( is_numeric($s) ) {
     68                $query .= " AND ( {$wpdb->blogs}.blog_id = '{$like_s}' )";
     69            } elseif ( is_subdomain_install() ) {
    6470                $blog_s = str_replace( '.' . $current_site->domain, '', $like_s );
    6571                $blog_s .= $wild . '.' . $current_site->domain;
    66                 $query .= " AND ( {$wpdb->blogs}.domain LIKE '$blog_s' ";
     72                $query .= " AND ( {$wpdb->blogs}.domain LIKE '$blog_s' ) ";
    6773            } else {
    6874                if ( $like_s != trim('/', $current_site->path) )
     
    7076                else
    7177                    $blog_s = $like_s;
    72                 $query .= " AND  ( {$wpdb->blogs}.path LIKE '$blog_s' ";
     78                $query .= " AND  ( {$wpdb->blogs}.path LIKE '$blog_s' )";
    7379            }
    74 
    75             if ( is_numeric($s) )
    76                 $query .= " OR {$wpdb->blogs}.blog_id = '{$like_s}' ";
    77 
    78             $query .= ' )';
    7980        }
    8081
     
    8788            $query .= ' ORDER BY domain ';
    8889        } else {
    89             $order_by = 'id';
    90             $query .= " ORDER BY {$wpdb->blogs}.blog_id ";
    91         }
    92 
    93         $order = ( isset( $_REQUEST['order'] ) && 'DESC' == strtoupper( $_REQUEST['order'] ) ) ? "DESC" : "ASC";
    94         $query .= $order;
     90            $order_by = null;
     91        }
     92
     93        if ( isset( $order_by ) ) {
     94            $order = ( isset( $_REQUEST['order'] ) && 'DESC' == strtoupper( $_REQUEST['order'] ) ) ? "DESC" : "ASC";
     95            $query .= $order;
     96        }
    9597
    9698        // Don't do an unbounded count on large networks
Note: See TracChangeset for help on using the changeset viewer.