Permalink
Browse files

MDL-32930 Improve the performance of get_tables

  • Loading branch information...
1 parent e16e230 commit c92e462b04ec92759cc11cd7161f40cc7c2850f3 @tmuras tmuras committed May 10, 2012
Showing with 3 additions and 7 deletions.
  1. +3 −7 lib/dml/mysqli_native_moodle_database.php
@@ -377,19 +377,15 @@ public function get_tables($usecache=true) {
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();

0 comments on commit c92e462

Please sign in to comment.