From 0bbfce9c6356f2677bd306ded2d5ea963bd5fad6 Mon Sep 17 00:00:00 2001 From: mattpiwik <matthieu.aubry@gmail.com> Date: Wed, 9 Jan 2013 04:41:08 +0000 Subject: [PATCH] fixing #3657 NEW config setting ; By default Piwik runs OPTIMIZE TABLE SQL queries to free spaces after deleting some data. ; If your Piwik tracks millions of pages, the OPTIMIZE TABLE queries might run for hours (seen in "SHOW FULL PROCESSLIST \g") ; so you can disable these special queries here: enable_sql_optimize_queries = 1 git-svn-id: http://dev.piwik.org/svn/trunk@7738 59fd770c-687e-43c8-a1e3-f5a4ff64c105 --- config/global.ini.php | 5 +++++ core/PluginsFunctions/Sql.php | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/config/global.ini.php b/config/global.ini.php index a85e72aa1f..f1e6f0b2fa 100644 --- a/config/global.ini.php +++ b/config/global.ini.php @@ -147,6 +147,11 @@ enable_browser_archiving_triggering = 1 ; At the moment, this is not needed in core but it can be handy for plugins enable_archive_parents_of_datatable = 0 +; By default Piwik runs OPTIMIZE TABLE SQL queries to free spaces after deleting some data. +; If your Piwik tracks millions of pages, the OPTIMIZE TABLE queries might run for hours (seen in "SHOW FULL PROCESSLIST \g") +; so you can disable these special queries here: +enable_sql_optimize_queries = 1 + ; MySQL minimum required version ; note: timezone support added in 4.1.3 minimum_mysql_version = 4.1 diff --git a/core/PluginsFunctions/Sql.php b/core/PluginsFunctions/Sql.php index 88b4624c62..0ab94bdc31 100644 --- a/core/PluginsFunctions/Sql.php +++ b/core/PluginsFunctions/Sql.php @@ -150,6 +150,11 @@ class Piwik_Sql */ static public function optimizeTables( $tables ) { + $optimize = Piwik_Config::getInstance()->General->enable_sql_optimize_queries; + if(empty($optimize)) { + return; + } + if(empty($tables)) { return false; @@ -163,7 +168,8 @@ class Piwik_Sql $nonInnoDbTables = array(); foreach (Piwik_FetchAll("SHOW TABLE STATUS") as $row) { - if (strtolower($row['Engine']) != 'innodb' && in_array($row['Name'], $tables)) + if (strtolower($row['Engine']) != 'innodb' + && in_array($row['Name'], $tables)) { $nonInnoDbTables[] = $row['Name']; } -- GitLab