r84905 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84904‎ | r84905 | r84906 >
Date:15:01, 28 March 2011
Author:catrope
Status:ok
Tags:
Comment:
BREAKING CHANGE: Ignore cmtype when cmsort=timestamp is set, and bypass the per-type queries in the sort=timestamp case; they were causing performance problems, reported as bug 28291. This breaks backwards compatibility (gracefully, the cltype parameter is silently ignored) with earlier deployed versions of 1.17wmf1 but not with any released version, hence no RELEASE-NOTES
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryCategoryMembers.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryCategoryMembers.php
@@ -160,26 +160,34 @@
161161 $limit = $params['limit'];
162162 $this->addOption( 'LIMIT', $limit + 1 );
163163
164 - // Run a separate SELECT query for each value of cl_type.
165 - // This is needed because cl_type is an enum, and MySQL has
166 - // inconsistencies between ORDER BY cl_type and
167 - // WHERE cl_type >= 'foo' making proper paging impossible
168 - // and unindexed.
169 - $rows = array();
170 - $first = true;
171 - foreach ( $queryTypes as $type ) {
172 - $extraConds = array( 'cl_type' => $type );
173 - if ( $first && $contWhere ) {
174 - // Continuation condition. Only added to the
175 - // first query, otherwise we'll skip things
176 - $extraConds[] = $contWhere;
 164+ if ( $params['sort'] == 'sortkey' ) {
 165+ // Run a separate SELECT query for each value of cl_type.
 166+ // This is needed because cl_type is an enum, and MySQL has
 167+ // inconsistencies between ORDER BY cl_type and
 168+ // WHERE cl_type >= 'foo' making proper paging impossible
 169+ // and unindexed.
 170+ $rows = array();
 171+ $first = true;
 172+ foreach ( $queryTypes as $type ) {
 173+ $extraConds = array( 'cl_type' => $type );
 174+ if ( $first && $contWhere ) {
 175+ // Continuation condition. Only added to the
 176+ // first query, otherwise we'll skip things
 177+ $extraConds[] = $contWhere;
 178+ }
 179+ $res = $this->select( __METHOD__, array( 'where' => $extraConds ) );
 180+ $rows = array_merge( $rows, iterator_to_array( $res ) );
 181+ if ( count( $rows ) >= $limit + 1 ) {
 182+ break;
 183+ }
 184+ $first = false;
177185 }
178 - $res = $this->select( __METHOD__, array( 'where' => $extraConds ) );
179 - $rows = array_merge( $rows, iterator_to_array( $res ) );
180 - if ( count( $rows ) >= $limit + 1 ) {
181 - break;
182 - }
183 - $first = false;
 186+ } else {
 187+ // Sorting by timestamp
 188+ // No need to worry about per-type queries because we
 189+ // aren't sorting or filtering by type anyway
 190+ $res = $this->select( __METHOD__ );
 191+ $rows = iterator_to_array( $res );
184192 }
185193 $count = 0;
186194 foreach ( $rows as $row ) {
@@ -334,7 +342,7 @@
335343 ' timestamp - Adds the timestamp of when the page was included',
336344 ),
337345 'namespace' => 'Only include pages in these namespaces',
338 - 'type' => 'What type of category members to include',
 346+ 'type' => "What type of category members to include. Ignored when {$p}sort=timestamp is set",
339347 'sort' => 'Property to sort by',
340348 'dir' => 'In which direction to sort',
341349 'start' => "Timestamp to start listing from. Can only be used with {$p}sort=timestamp",

Sign-offs

UserFlagDate
Reedyinspected15:13, 28 March 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r849081.17wmf1: MFT r84905catrope16:52, 28 March 2011
r85435MFT: r84431, r84464, r84543, r84553, r84573, r84574, r84577, r84729, r84765, ...demon14:00, 5 April 2011

Status & tagging log