r25410 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25409‎ | r25410 | r25411 >
Date:18:03, 2 September 2007
Author:greg
Status:old
Tags:
Comment:
Add implicitOrderby() to make sure that SpecialAllpages uses an ORDER BY when needed.
Made this an option rather than forcing the ORDER BY as testing show MySQL is
faster without it for large tables.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Database.php (modified) (history)
  • /trunk/phase3/includes/DatabaseOracle.php (modified) (history)
  • /trunk/phase3/includes/DatabasePostgres.php (modified) (history)
  • /trunk/phase3/includes/SpecialAllpages.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialAllpages.php
@@ -101,7 +101,11 @@
102102 $lines = $wgMemc->get( $key );
103103
104104 if( !is_array( $lines ) ) {
105 - $firstTitle = $dbr->selectField( 'page', 'page_title', $where, $fname, array( 'LIMIT' => 1 ) );
 105+ $options = array( 'LIMIT' => 1 );
 106+ if ( ! $dbr->implicitOrderby() ) {
 107+ $options['ORDER BY'] = 'page_title';
 108+ }
 109+ $firstTitle = $dbr->selectField( 'page', 'page_title', $where, $fname, $options );
106110 $lastTitle = $firstTitle;
107111
108112 # This array is going to hold the page_titles in order.
@@ -293,8 +297,11 @@
294298 } else {
295299 # The previous chunk is not complete, need to link to the very first title
296300 # available in the database
297 - $reallyFirstPage_title = $dbr->selectField( 'page', 'page_title', array( 'page_namespace' => $namespace ), $fname, array( 'LIMIT' => 1) );
298 -
 301+ $options = array( 'LIMIT' => 1 );
 302+ if ( ! $dbr->implicitOrderby() ) {
 303+ $options['ORDER BY'] = 'page_title';
 304+ }
 305+ $reallyFirstPage_title = $dbr->selectField( 'page', 'page_title', array( 'page_namespace' => $namespace ), $fname, $options );
299306 # Show the previous link if it s not the current requested chunk
300307 if( $from != $reallyFirstPage_title ) {
301308 $prevTitle = Title::makeTitle( $namespace, $reallyFirstPage_title );
Index: trunk/phase3/includes/DatabaseOracle.php
@@ -128,6 +128,9 @@
129129 function implicitGroupby() {
130130 return false;
131131 }
 132+ function implicitOrderby() {
 133+ return false;
 134+ }
132135 function searchableIPs() {
133136 return true;
134137 }
Index: trunk/phase3/includes/DatabasePostgres.php
@@ -102,6 +102,9 @@
103103 function implicitGroupby() {
104104 return false;
105105 }
 106+ function implicitOrderby() {
 107+ return false;
 108+ }
106109 function searchableIPs() {
107110 return true;
108111 }
Index: trunk/phase3/includes/Database.php
@@ -441,6 +441,14 @@
442442 }
443443
444444 /**
 445+ * Returns true if this database does an implicit order by when the column has an index
 446+ * For example: SELECT page_title FROM page LIMIT 1
 447+ */
 448+ function implicitOrderby() {
 449+ return true;
 450+ }
 451+
 452+ /**
445453 * Returns true if this database can do a native search on IP columns
446454 * e.g. this works as expected: .. WHERE rc_ip = '127.42.12.102/32';
447455 */
Index: trunk/phase3/RELEASE-NOTES
@@ -429,6 +429,8 @@
430430 * (bug 8393) <sup> and <sub> need to be preserved (without attributes) for
431431 entries in the table of contents
432432 * (bug 11114) Fix regression in read-only mode error display during editing
 433+* Force non-MySQL databases to use an ORDER BY in SpecialAllpages to ensure
 434+ that the first page_title is truly the first page title.
433435
434436 == API changes since 1.10 ==
435437

Follow-up revisions

RevisionCommit summaryAuthorDate
r25415Merged revisions 25372-25414 via svnmerge from...david21:15, 2 September 2007

Status & tagging log