mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
use join to speed up cleanup
This commit is contained in:
@@ -5,8 +5,6 @@ import java.util.List;
|
|||||||
import com.commafeed.backend.model.FeedEntryContent;
|
import com.commafeed.backend.model.FeedEntryContent;
|
||||||
import com.commafeed.backend.model.QFeedEntry;
|
import com.commafeed.backend.model.QFeedEntry;
|
||||||
import com.commafeed.backend.model.QFeedEntryContent;
|
import com.commafeed.backend.model.QFeedEntryContent;
|
||||||
import com.querydsl.jpa.JPAExpressions;
|
|
||||||
import com.querydsl.jpa.JPQLSubQuery;
|
|
||||||
|
|
||||||
import jakarta.inject.Singleton;
|
import jakarta.inject.Singleton;
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
@@ -26,9 +24,13 @@ public class FeedEntryContentDAO extends GenericDAO<FeedEntryContent> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public long deleteWithoutEntries(int max) {
|
public long deleteWithoutEntries(int max) {
|
||||||
JPQLSubQuery<Integer> subQuery = JPAExpressions.selectOne().from(ENTRY).where(ENTRY.content.id.eq(CONTENT.id));
|
List<Long> ids = query().select(CONTENT.id)
|
||||||
List<Long> ids = query().select(CONTENT.id).from(CONTENT).where(subQuery.notExists()).limit(max).fetch();
|
.from(CONTENT)
|
||||||
|
.leftJoin(ENTRY)
|
||||||
|
.on(ENTRY.content.id.eq(CONTENT.id))
|
||||||
|
.where(ENTRY.id.isNull())
|
||||||
|
.limit(max)
|
||||||
|
.fetch();
|
||||||
return deleteQuery(CONTENT).where(CONTENT.id.in(ids)).execute();
|
return deleteQuery(CONTENT).where(CONTENT.id.in(ids)).execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user