+ return (['list' => $statelist, 'amount' => $processes]);
+ }
+
+ /**
+ * Optimizes tables
+ *
+ * @param string $table a given table
+ *
+ * @return bool True, if successfully optimized, otherwise false
+ * @throws \Exception
+ */
+ public function optimizeTable(string $table): bool
+ {
+ return $this->e("OPTIMIZE TABLE " . DBA::buildTableString([$table])) !== false;
+ }
+
+ /**
+ * Kill sleeping database processes
+ *
+ * @return void
+ */
+ public function deleteSleepingProcesses()
+ {
+ $processes = $this->p("SHOW FULL PROCESSLIST");
+ while ($process = $this->fetch($processes)) {
+ if (($process['Command'] != 'Sleep') || ($process['Time'] < 300) || ($process['db'] != $this->databaseName())) {
+ continue;
+ }
+
+ $this->e("KILL ?", $process['Id']);
+ }
+ $this->close($processes);