diff --git a/core/Db.php b/core/Db.php
index 25409ecce5f05cee9a961e5fc0d6dc65d7627c90..8c718ceac5b8c3a5da35f0db3628e82f70f25951 100644
--- a/core/Db.php
+++ b/core/Db.php
@@ -324,7 +324,7 @@ class Db
         $optimize = Config::getInstance()->General['enable_sql_optimize_queries'];
 
         if (empty($optimize)) {
-            return;
+            return false;
         }
 
         if (empty($tables)) {
@@ -345,14 +345,16 @@ class Db
                     $myisamDbTables[] = $row['Name'];
                 }
             }
+
+            $tables = $myisamDbTables;
         }
 
-        if (empty($myisamDbTables)) {
+        if (empty($tables)) {
             return false;
         }
 
         // optimize the tables
-        return self::query("OPTIMIZE TABLE " . implode(',', $myisamDbTables));
+        return self::query("OPTIMIZE TABLE " . implode(',', $tables));
     }
 
     private static function getTableStatus()