r39455 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r39454‎ | r39455 | r39456 >
Date:03:43, 16 August 2008
Author:aaron
Status:old
Tags:
Comment:
* Go back to regular counts for bail out check, but only when a period is given, otherwise, estimates are fine
* Improve edit count estimates
Modified paths:
  • /trunk/extensions/CheckUser/CheckUser_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CheckUser/CheckUser_body.php
@@ -298,10 +298,18 @@
299299 # Also, if we only show 5000, too many will be ignored as well.
300300 $index = $xfor ? 'cuc_xff_hex_time' : 'cuc_ip_hex_time';
301301 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+ }
306314 }
307315 # See what is best to do after testing the waters...
308316 if( isset($rangecount) && $rangecount > 5000 ) {
@@ -628,10 +636,18 @@
629637 # Ordered in descent by timestamp. Can cause large filesorts on range scans.
630638 # Check how many rows will need sorting ahead of time to see if this is too big.
631639 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+ }
636652 }
637653 // Are there too many edits?
638654 if( isset($rangecount) && $rangecount > 5000 ) {
@@ -975,18 +991,16 @@
976992
977993 # If we get some results, it helps to know if the IP in general
978994 # 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 ) {
9851000 $ipedits = $dbr->selectField( 'cu_changes', 'COUNT(*)',
9861001 array( 'cuc_ip_hex' => $ips_hex[$ip] ),
9871002 __METHOD__ );
9881003 }
989 - # Kludge a little for estimates...
990 - if( !$wgMiserMode || $ipedits > (1.5*$ips_edits[$ip]) ) {
 1004+ if( $ipedits > $ips_edits[$ip] ) {
9911005 $s .= ' <i>(' . wfMsgHtml('checkuser-ipeditcount',$ipedits) . ')</i>';
9921006 }
9931007

Status & tagging log