jenkins-bot has submitted this change and it was merged.
Change subject: Optimize count queries
......................................................................
Optimize count queries
Use nested selects to count the number of rows on server and avoid pointlessly
sending 500 rows to apaches.
Change-Id: I08182b7626dcf0509d1dc5f5aa8e87814c153acc
---
M includes/specials/SpecialUserProfile.php
1 file changed, 16 insertions(+), 6 deletions(-)
Approvals:
Jdlrobson: Looks good to me, but someone else must approve
Springle: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/specials/SpecialUserProfile.php
b/includes/specials/SpecialUserProfile.php
index 17f8ce8..dac85ec 100644
--- a/includes/specials/SpecialUserProfile.php
+++ b/includes/specials/SpecialUserProfile.php
@@ -41,10 +41,15 @@
$constraints = array(
'limit' => self::LIMIT + 1,
);
- $res = $dbr->select( 'recentchanges', 'rc_timestamp', $where,
__METHOD__, $constraints );
- $res = $res->numRows();
+ $innerSelect = $dbr->selectSQLText( 'recentchanges',
'rc_timestamp', $where, __METHOD__, $constraints );
+ $res = $dbr->query( "SELECT COUNT(*) FROM ($innerSelect) t",
__METHOD__ );
+ $row = $res->fetchRow();
+ $result = 0;
+ if ( $row ) {
+ $result = $row[0];
+ }
wfProfileOut( __METHOD__ );
- return $res;
+ return $result;
}
/**
@@ -76,10 +81,15 @@
$constraints = array(
'limit' => self::LIMIT + 1,
);
- $res = $dbr->select( 'image', 'img_timestamp', $where,
__METHOD__, $constraints );
- $res = $res->numRows();
+ $innerSelect = $dbr->selectSQLText( 'image', 'img_timestamp',
$where, __METHOD__, $constraints );
+ $res = $dbr->query( "SELECT COUNT(*) FROM ($innerSelect) t",
__METHOD__ );
+ $row = $res->fetchRow();
+ $result = 0;
+ if ( $row ) {
+ $result = $row[0];
+ }
wfProfileOut( __METHOD__ );
- return $res;
+ return $result;
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/86683
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I08182b7626dcf0509d1dc5f5aa8e87814c153acc
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: MaxSem <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Springle <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits