From db5078d51c7b01a6beb7145c866e38d02b2eb284 Mon Sep 17 00:00:00 2001 From: Philipp Date: Sat, 13 May 2023 21:05:22 +0200 Subject: [PATCH] Move "OPTIMIZE TABLE" to own Database function --- src/Database/Database.php | 13 +++++++++++++ src/Federation/Repository/DeliveryQueueItem.php | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Database/Database.php b/src/Database/Database.php index b1ea6c1e4f..b1e31bda74 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -1758,6 +1758,19 @@ class Database 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; + } + /** * Fetch a database variable * diff --git a/src/Federation/Repository/DeliveryQueueItem.php b/src/Federation/Repository/DeliveryQueueItem.php index 815cf89b50..59afd5a3ad 100644 --- a/src/Federation/Repository/DeliveryQueueItem.php +++ b/src/Federation/Repository/DeliveryQueueItem.php @@ -108,6 +108,6 @@ final class DeliveryQueueItem extends \Friendica\BaseRepository public function optimizeStorage(): bool { - return $this->db->e("OPTIMIZE TABLE " . DBA::buildTableString([self::$table_name])); + return $this->db->optimizeTable(self::$table_name); } } -- 2.39.5