diff --git a/lib/Collection.php b/lib/Collection.php index 9763d4ac..d50e26be 100644 --- a/lib/Collection.php +++ b/lib/Collection.php @@ -104,10 +104,10 @@ class Collection{ */ public static function DeleteUnused(): void{ Db::Query(' - DELETE - from Collections - where CollectionId not in - (select distinct CollectionId from CollectionEbooks) + DELETE c + from Collections c + left join CollectionEbooks ce using (CollectionId) + where ce.CollectionId is null '); } diff --git a/lib/EbookTag.php b/lib/EbookTag.php index bfa6fcaf..138a3184 100644 --- a/lib/EbookTag.php +++ b/lib/EbookTag.php @@ -113,11 +113,11 @@ class EbookTag extends Tag{ */ public static function DeleteUnused(): void{ Db::Query(' - DELETE - from Tags - where Type = ? - and TagId not in - (select distinct TagId from EbookTags) + DELETE t + from Tags t + left join EbookTags et using (TagId) + where t.Type = ? + and et.TagId is null ', [Enums\TagType::Ebook]); } } diff --git a/lib/LocSubject.php b/lib/LocSubject.php index 880fb3a1..36d4bf07 100644 --- a/lib/LocSubject.php +++ b/lib/LocSubject.php @@ -70,10 +70,10 @@ class LocSubject{ */ public static function DeleteUnused(): void{ Db::Query(' - DELETE - from LocSubjects - where LocSubjectId not in - (select distinct LocSubjectId from EbookLocSubjects) + DELETE ls + from LocSubjects ls + left join EbookLocSubjects els using (LocSubjectId) + where els.LocSubjectId is null '); } }