Index: trunk/extensions/CheckUser/CheckUser_body.php |
— | — | @@ -298,10 +298,18 @@ |
299 | 299 | # Also, if we only show 5000, too many will be ignored as well. |
300 | 300 | $index = $xfor ? 'cuc_xff_hex_time' : 'cuc_ip_hex_time'; |
301 | 301 | if( strpos($ip,'/') !==false ) { |
302 | | - $rangecount = $dbr->estimateRowCount( 'cu_changes', '*', |
303 | | - array( $ip_conds, $time_conds ), |
304 | | - __METHOD__, |
305 | | - array( 'USE INDEX' => $index ) ); |
| 302 | + # Quick index check only OK if no time constraint |
| 303 | + if( $period ) { |
| 304 | + $rangecount = $dbr->selectField( 'cu_changes', 'COUNT(*)', |
| 305 | + array( $ip_conds, $time_conds ), |
| 306 | + __METHOD__, |
| 307 | + array( 'USE INDEX' => $index ) ); |
| 308 | + } else { |
| 309 | + $rangecount = $dbr->estimateRowCount( 'cu_changes', '*', |
| 310 | + array( $ip_conds ), |
| 311 | + __METHOD__, |
| 312 | + array( 'USE INDEX' => $index ) ); |
| 313 | + } |
306 | 314 | } |
307 | 315 | # See what is best to do after testing the waters... |
308 | 316 | if( isset($rangecount) && $rangecount > 5000 ) { |
— | — | @@ -628,10 +636,18 @@ |
629 | 637 | # Ordered in descent by timestamp. Can cause large filesorts on range scans. |
630 | 638 | # Check how many rows will need sorting ahead of time to see if this is too big. |
631 | 639 | if( strpos($ip,'/') !==false ) { |
632 | | - $rangecount = $dbr->estimateRowCount( 'cu_changes', '*', |
633 | | - array( $ip_conds, $time_conds ), |
634 | | - __METHOD__, |
635 | | - array( 'USE INDEX' => $index ) ); |
| 640 | + # Quick index check only OK if no time constraint |
| 641 | + if( $period ) { |
| 642 | + $rangecount = $dbr->selectField( 'cu_changes', 'COUNT(*)', |
| 643 | + array( $ip_conds, $time_conds ), |
| 644 | + __METHOD__, |
| 645 | + array( 'USE INDEX' => $index ) ); |
| 646 | + } else { |
| 647 | + $rangecount = $dbr->estimateRowCount( 'cu_changes', '*', |
| 648 | + array( $ip_conds ), |
| 649 | + __METHOD__, |
| 650 | + array( 'USE INDEX' => $index ) ); |
| 651 | + } |
636 | 652 | } |
637 | 653 | // Are there too many edits? |
638 | 654 | if( isset($rangecount) && $rangecount > 5000 ) { |
— | — | @@ -975,18 +991,16 @@ |
976 | 992 | |
977 | 993 | # If we get some results, it helps to know if the IP in general |
978 | 994 | # has a lot more edits, e.g. "tip of the iceberg"... |
979 | | - global $wgMiserMode; |
980 | | - if( $wgMiserMode ) { |
981 | | - $ipedits = $dbr->estimateRowCount( 'cu_changes', '*', |
982 | | - array( 'cuc_ip_hex' => $ips_hex[$ip] ), |
983 | | - __METHOD__ ); |
984 | | - } else { |
| 995 | + $ipedits = $dbr->estimateRowCount( 'cu_changes', '*', |
| 996 | + array( 'cuc_ip_hex' => $ips_hex[$ip] ), |
| 997 | + __METHOD__ ); |
| 998 | + # If small enough, get a more accurate count |
| 999 | + if( $ipedits <= 1000 ) { |
985 | 1000 | $ipedits = $dbr->selectField( 'cu_changes', 'COUNT(*)', |
986 | 1001 | array( 'cuc_ip_hex' => $ips_hex[$ip] ), |
987 | 1002 | __METHOD__ ); |
988 | 1003 | } |
989 | | - # Kludge a little for estimates... |
990 | | - if( !$wgMiserMode || $ipedits > (1.5*$ips_edits[$ip]) ) { |
| 1004 | + if( $ipedits > $ips_edits[$ip] ) { |
991 | 1005 | $s .= ' <i>(' . wfMsgHtml('checkuser-ipeditcount',$ipedits) . ')</i>'; |
992 | 1006 | } |
993 | 1007 | |