mirror of
https://github.com/Yetangitu/ampache
synced 2025-10-05 10:49:37 +02:00
Move Catalog::optimize_tables() to Dba
This commit is contained in:
parent
7703c9431d
commit
fd5b7e1b10
4 changed files with 25 additions and 24 deletions
|
@ -95,7 +95,7 @@ switch ($_REQUEST['action']) {
|
||||||
$catalog->count = 0;
|
$catalog->count = 0;
|
||||||
$catalog->add_to_catalog();
|
$catalog->add_to_catalog();
|
||||||
}
|
}
|
||||||
Catalog::optimize_tables();
|
Dba::optimize_tables();
|
||||||
$url = Config::get('web_path') . '/admin/catalog.php';
|
$url = Config::get('web_path') . '/admin/catalog.php';
|
||||||
$title = T_('Catalog Updated');
|
$title = T_('Catalog Updated');
|
||||||
$body = '';
|
$body = '';
|
||||||
|
@ -153,7 +153,7 @@ switch ($_REQUEST['action']) {
|
||||||
$catalog = new Catalog($catalog_id);
|
$catalog = new Catalog($catalog_id);
|
||||||
$catalog->clean_catalog();
|
$catalog->clean_catalog();
|
||||||
} // end foreach catalogs
|
} // end foreach catalogs
|
||||||
Catalog::optimize_tables();
|
Dba::optimize_tables();
|
||||||
}
|
}
|
||||||
|
|
||||||
$url = Config::get('web_path') . '/admin/catalog.php';
|
$url = Config::get('web_path') . '/admin/catalog.php';
|
||||||
|
|
|
@ -141,7 +141,7 @@ while ($row = Dba::fetch_row($db_results)) {
|
||||||
|
|
||||||
} // end foreach
|
} // end foreach
|
||||||
|
|
||||||
Catalog::optimize_tables();
|
Dba::optimize_tables();
|
||||||
|
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
echo "\n";
|
echo "\n";
|
||||||
|
|
|
@ -1525,27 +1525,6 @@ class Catalog extends database_object {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* optimize_tables
|
|
||||||
* This runs an optimize on the tables and updates the stats to improve
|
|
||||||
* join speed.
|
|
||||||
* This can be slow, but is a good idea to do from time to time. We do
|
|
||||||
* it in case the dba isn't doing it... which we're going to assume they
|
|
||||||
* aren't
|
|
||||||
*/
|
|
||||||
public static function optimize_tables() {
|
|
||||||
$sql = "SHOW TABLES";
|
|
||||||
$db_results = Dba::read($sql);
|
|
||||||
|
|
||||||
while($row = Dba::fetch_row($db_results)) {
|
|
||||||
$sql = "OPTIMIZE TABLE `" . $row[0] . "`";
|
|
||||||
$db_results_inner = Dba::write($sql);
|
|
||||||
|
|
||||||
$sql = "ANALYZE TABLE `" . $row[0] . "`";
|
|
||||||
$db_results_inner = Dba::write($sql);
|
|
||||||
}
|
|
||||||
} // optimize_tables;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* trim_prefix
|
* trim_prefix
|
||||||
* Splits the prefix from the string
|
* Splits the prefix from the string
|
||||||
|
|
|
@ -506,6 +506,28 @@ class Dba {
|
||||||
|
|
||||||
} // reset_db_charset
|
} // reset_db_charset
|
||||||
|
|
||||||
|
/**
|
||||||
|
* optimize_tables
|
||||||
|
*
|
||||||
|
* This runs an optimize on the tables and updates the stats to improve
|
||||||
|
* join speed.
|
||||||
|
* This can be slow, but is a good idea to do from time to time. We do
|
||||||
|
* it in case the dba isn't doing it... which we're going to assume they
|
||||||
|
* aren't.
|
||||||
|
*/
|
||||||
|
public static function optimize_tables() {
|
||||||
|
$sql = "SHOW TABLES";
|
||||||
|
$db_results = Dba::read($sql);
|
||||||
|
|
||||||
|
while($row = Dba::fetch_row($db_results)) {
|
||||||
|
$sql = "OPTIMIZE TABLE `" . $row[0] . "`";
|
||||||
|
$db_results_inner = Dba::write($sql);
|
||||||
|
|
||||||
|
$sql = "ANALYZE TABLE `" . $row[0] . "`";
|
||||||
|
$db_results_inner = Dba::write($sql);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // dba class
|
} // dba class
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue