* SearchEngine::textAlreadyUpdatedForIndex() is deprecated, given the
deprecation above this method is no longer needed/called and should not be
implemented by SearchEngine implementation.
+* IDatabase::bufferResults() has been deprecated. Use query batching instead.
=== Other changes in 1.34 ===
* …
return $this->__call( __FUNCTION__, func_get_args() );
}
+ /**
+ * @param bool|null $buffer
+ * @return bool
+ * @deprecated Since 1.34 Use query batching
+ */
public function bufferResults( $buffer = null ) {
return $this->__call( __FUNCTION__, func_get_args() );
}
return $this->getServerVersion();
}
+ /**
+ * Turns buffering of SQL result sets on (true) or off (false). Default is "on".
+ *
+ * Unbuffered queries are very troublesome in MySQL:
+ *
+ * - If another query is executed while the first query is being read
+ * out, the first query is killed. This means you can't call normal
+ * Database functions while you are reading an unbuffered query result
+ * from a normal Database connection.
+ *
+ * - Unbuffered queries cause the MySQL server to use large amounts of
+ * memory and to hold broad locks which block other queries.
+ *
+ * If you want to limit client-side memory, it's almost always better to
+ * split up queries into batches using a LIMIT clause than to switch off
+ * buffering.
+ *
+ * @param null|bool $buffer
+ * @return bool The previous value of the flag
+ * @deprecated Since 1.34 Use query batching
+ */
public function bufferResults( $buffer = null ) {
$res = !$this->getFlag( self::DBO_NOBUFFER );
if ( $buffer !== null ) {
protected function doQuery( $sql ) {
$conn = $this->getBindingHandle();
- if ( $this->bufferResults() ) {
- $ret = $conn->query( $sql );
- } else {
+ if ( $this->getFlag( self::DBO_NOBUFFER ) ) {
$ret = $conn->query( $sql, MYSQLI_USE_RESULT );
+ } else {
+ $ret = $conn->query( $sql );
}
return $ret;
*/
public function getServerInfo();
- /**
- * Turns buffering of SQL result sets on (true) or off (false). Default is "on".
- *
- * Unbuffered queries are very troublesome in MySQL:
- *
- * - If another query is executed while the first query is being read
- * out, the first query is killed. This means you can't call normal
- * Database functions while you are reading an unbuffered query result
- * from a normal Database connection.
- *
- * - Unbuffered queries cause the MySQL server to use large amounts of
- * memory and to hold broad locks which block other queries.
- *
- * If you want to limit client-side memory, it's almost always better to
- * split up queries into batches using a LIMIT clause than to switch off
- * buffering.
- *
- * @param null|bool $buffer
- * @return null|bool The previous value of the flag
- */
- public function bufferResults( $buffer = null );
-
/**
* Gets the current transaction level.
*
$this->output( "Loading IDs from $cur table...\n" );
$this->performanceLog( $fh, "Reading $numRows rows from cur table...\n" );
$this->performanceLog( $fh, "rows read vs seconds elapsed:\n" );
+ $contentLang = MediaWikiServices::getInstance()->getContentLanguage();
- $dbw->bufferResults( false );
- $res = $dbw->query( "SELECT cur_namespace,cur_title,cur_id FROM $cur" );
$ids = [];
-
- foreach ( $res as $row ) {
- $title = $row->cur_title;
- if ( $row->cur_namespace ) {
- $title = MediaWikiServices::getInstance()->getContentLanguage()->
- getNsText( $row->cur_namespace ) . ":$title";
- }
- $ids[$title] = $row->cur_id;
- $curRowsRead++;
- if ( $reportCurReadProgress ) {
- if ( ( $curRowsRead % $curReadReportInterval ) == 0 ) {
- $this->performanceLog(
- $fh,
- $curRowsRead . " " . ( microtime( true ) - $baseTime ) . "\n"
- );
- $this->output( "\t$curRowsRead rows of $cur table read.\n" );
+ $lastId = 0;
+ do {
+ $res = $dbw->query(
+ "SELECT cur_namespace,cur_title,cur_id FROM $cur " .
+ "WHERE cur_id > $lastId ORDER BY cur_id LIMIT 10000"
+ );
+ foreach ( $res as $row ) {
+ $title = $row->cur_title;
+ if ( $row->cur_namespace ) {
+ $title = $contentLang->getNsText( $row->cur_namespace ) . ":$title";
+ }
+ $ids[$title] = $row->cur_id;
+ $curRowsRead++;
+ if ( $reportCurReadProgress ) {
+ if ( ( $curRowsRead % $curReadReportInterval ) == 0 ) {
+ $this->performanceLog(
+ $fh,
+ $curRowsRead . " " . ( microtime( true ) - $baseTime ) . "\n"
+ );
+ $this->output( "\t$curRowsRead rows of $cur table read.\n" );
+ }
}
+ $lastId = $row->cur_id;
}
- }
- $dbw->bufferResults( true );
+ } while ( $res->numRows() > 0 );
$this->output( "Finished loading IDs.\n\n" );
$this->performanceLog(
$fh,