summaryrefslogtreecommitdiffstats
path: root/lib/class/dba.class.php
diff options
context:
space:
mode:
authorPaul Arthur <paul.arthur@flowerysong.com>2013-01-26 00:23:12 -0500
committerPaul Arthur <paul.arthur@flowerysong.com>2013-01-26 00:23:12 -0500
commitfd5b7e1b10c00738f1a27f94c5ee529352dd68ca (patch)
tree2ec56c4f940ccfd50754aa5d250a5678c6d8e19e /lib/class/dba.class.php
parent7703c9431d6989af12e9c75a35cf8f641482a81f (diff)
downloadampache-fd5b7e1b10c00738f1a27f94c5ee529352dd68ca.tar.gz
ampache-fd5b7e1b10c00738f1a27f94c5ee529352dd68ca.tar.bz2
ampache-fd5b7e1b10c00738f1a27f94c5ee529352dd68ca.zip
Move Catalog::optimize_tables() to Dba
Diffstat (limited to 'lib/class/dba.class.php')
-rw-r--r--lib/class/dba.class.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/class/dba.class.php b/lib/class/dba.class.php
index 8ec5eed5..ce5c38c4 100644
--- a/lib/class/dba.class.php
+++ b/lib/class/dba.class.php
@@ -506,6 +506,28 @@ class Dba {
} // 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
?>