r22786 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22785‎ | r22786 | r22787 >
Date:04:38, 6 June 2007
Author:aaron
Status:old
Tags:
Comment:
*Try to use rev_len first to avoid hitting text table as much
Modified paths:
  • /trunk/phase3/maintenance/rebuildrecentchanges.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/rebuildrecentchanges.inc
@@ -64,16 +64,19 @@
6565 # Switch! Look up the previous last edit, if any
6666 $lastCurId = intval( $obj->rc_cur_id );
6767 $emit = $obj->rc_timestamp;
68 - $sql2 = "SELECT rev_id, rev_text_id FROM $revision " .
 68+ $sql2 = "SELECT rev_id, rev_len, rev_text_id FROM $revision " .
6969 "WHERE rev_page={$lastCurId} ".
7070 "AND rev_timestamp<'{$emit}' ORDER BY rev_timestamp DESC LIMIT 1";
7171 $res2 = $dbw->query( $sql2 );
7272 if( $row = $dbw->fetchObject( $res2 ) ) {
7373 $lastOldId = intval( $row->rev_id );
7474 $lastTextId = intval( $row->rev_text_id );
 75+ $lastSize = $row->rev_len; # Grab the last text size
7576 } else {
7677 # No previous edit
77 - $lastOldId = $lastTextId = 0;
 78+ $lastOldId = 0;
 79+ $lastTextId = 0;
 80+ $lastSize = NULL;
7881 $new = 1;
7982 }
8083 $dbw->freeResult( $res2 );
@@ -81,18 +84,31 @@
8285 if( $lastCurId == 0 ) {
8386 print "Uhhh, something wrong? No curid\n";
8487 } else {
85 - # Grab the last edit's text size
86 - $lastText = $dbw->selectField( 'text', 'old_text', array('old_id' => $lastTextId ) );
87 - $lastSize = $lastText ? strlen($lastText) : 'NULL';
 88+ # Check the text if not in rev_len for the last entry's text size
 89+ if( !$lastSize ) {
 90+ $lastText = $dbw->selectField( 'text', 'old_text', array('old_id' => $lastTextId ) );
 91+ $lastSize = $lastText ? strlen($lastText) : 'NULL';
 92+ }
8893 # Grab the entry's text size
89 - $textId = $dbw->selectField( 'revision', 'rev_text_id', array('rev_id' => $obj->rc_this_oldid ) );
90 - $text = $dbw->selectField( 'text', 'old_text', array('old_id' => $textId ) );
91 - $size = $text ? strlen($text) : 'NULL';
 94+ $res3 = $dbw->select( 'revision', array('rev_len','rev_text_id'), array('rev_id' => $obj->rc_this_oldid ) );
 95+ if( $row = $dbw->fetchObject( $res3 ) ) {
 96+ $textId = $row->rev_text_id;
 97+ $size = $row->rev_len;
 98+ } else {
 99+ $textId = 0;
 100+ $size = NULL;
 101+ }
 102+ # Check the text if not in rev_len for the entry's text size
 103+ if( !$size ) {
 104+ $text = $dbw->selectField( 'text', 'old_text', array('old_id' => $textId ) );
 105+ $size = $text ? strlen($text) : 'NULL';
 106+ }
92107
93108 $sql3 = "UPDATE $recentchanges SET rc_last_oldid=$lastOldId,rc_new=$new,rc_type=$new," .
94 - "rc_old_len=$lastSize,rc_new_len=$size " .
 109+ "rc_old_len='$lastSize',rc_new_len='$size' " .
95110 "WHERE rc_cur_id={$lastCurId} AND rc_this_oldid={$obj->rc_this_oldid}";
96111 $dbw->query( $sql3 );
 112+
97113 $lastOldId = intval( $obj->rc_this_oldid );
98114 }
99115 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r22791Merged revisions 22747-22790 via svnmerge from...david09:21, 6 June 2007

Status & tagging log