Skip to content
Snippets Groups Projects
Commit a49c00b5 authored by matthiasgrimm's avatar matthiasgrimm
Browse files

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
parent 34342902
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment