MDL-32930 Improve the performance of get_tables

This commit is contained in:
Tomasz Muras 2012-05-10 23:35:18 +02:00
parent e16e2300c5
commit c92e462b04

View File

@ -377,19 +377,15 @@ class mysqli_native_moodle_database extends moodle_database {
return $this->tables;
}
$this->tables = array();
$sql = "SHOW TABLES";
$sql = "SHOW TABLES LIKE '{$this->prefix}%'";
$this->query_start($sql, null, SQL_QUERY_AUX);
$result = $this->mysqli->query($sql);
$this->query_end($result);
$len = strlen($this->prefix);
if ($result) {
while ($arr = $result->fetch_assoc()) {
$tablename = reset($arr);
if ($this->prefix !== '') {
if (strpos($tablename, $this->prefix) !== 0) {
continue;
}
$tablename = substr($tablename, strlen($this->prefix));
}
$tablename = substr($tablename, $len);
$this->tables[$tablename] = $tablename;
}
$result->close();