summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatthiasgrimm <matthiasgrimm@users.sourceforge.net>2006-01-26 21:57:15 +0100
committermatthiasgrimm <matthiasgrimm@users.sourceforge.net>2006-01-26 21:57:15 +0100
commita49c00b5b5cc87a6f9acf0f53da1f44dd5d8b9f8 (patch)
tree6397ccd7280d65dd60d25aba7efba9a36266eac7
parent343429022f6f60588a139e6b7ba9f6fed654ae45 (diff)
downloadrpg-a49c00b5b5cc87a6f9acf0f53da1f44dd5d8b9f8.tar.gz
rpg-a49c00b5b5cc87a6f9acf0f53da1f44dd5d8b9f8.tar.bz2
MySQL getUserCount() optimizsation
The function getUserCount() uses SQL_CALC_FOUND_ROWS now if MySQL v4.0 or later is found. This will speed up this query with big user tables. darcs-hash:20060126205715-7ef76-e3a7009ad6be3659002b562bc055e4fe1cbd904a.gz
-rw-r--r--inc/auth/mysql.class.php13
1 files changed, 10 insertions, 3 deletions
diff --git a/inc/auth/mysql.class.php b/inc/auth/mysql.class.php
index 2642ebd4c..cc53ab073 100644
--- a/inc/auth/mysql.class.php
+++ b/inc/auth/mysql.class.php
@@ -242,9 +242,16 @@ class auth_mysql extends auth_basic {
if($this->_openDB()) {
$sql = $this->_createSQLFilter($this->cnf['getUsers'], $filter);
- $result = $this->_queryDB($sql);
- if ($result)
- $rc = count($result);
+
+ if ($this->dbver >= 4) {
+ $sql = substr($sql, 6); /* remove 'SELECT' or 'select' */
+ $sql = "SELECT SQL_CALC_FOUND_ROWS".$sql." LIMIT 1";
+ $this->_queryDB($sql);
+ $result = $this->_queryDB("SELECT FOUND_ROWS()");
+ $rc = $result[0]['FOUND_ROWS()'];
+ } else if (($result = $this->_queryDB($sql)))
+ $rc = count($result);
+
$this->_closeDB();
}
return $rc;