From 28104cc7e46dfa7cf76341ef74bd218d0f4c6ed7 Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Thu, 17 Nov 2022 04:38:24 +0000 Subject: [PATCH] Right join when querying table to avoid full scan. --- .../piped/server/handlers/auth/AuthPlaylistHandlers.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/kavin/piped/server/handlers/auth/AuthPlaylistHandlers.java b/src/main/java/me/kavin/piped/server/handlers/auth/AuthPlaylistHandlers.java index 7a4728b..e6272f4 100644 --- a/src/main/java/me/kavin/piped/server/handlers/auth/AuthPlaylistHandlers.java +++ b/src/main/java/me/kavin/piped/server/handlers/auth/AuthPlaylistHandlers.java @@ -223,7 +223,7 @@ public class AuthPlaylistHandlers { var cb = s.getCriteriaBuilder(); var query = cb.createQuery(me.kavin.piped.utils.obj.db.Playlist.class); var root = query.from(me.kavin.piped.utils.obj.db.Playlist.class); - root.fetch("videos", JoinType.LEFT); + root.fetch("videos", JoinType.RIGHT); query.where(cb.equal(root.get("playlist_id"), UUID.fromString(playlistId))); var playlist = s.createQuery(query).uniqueResult(); @@ -278,7 +278,7 @@ public class AuthPlaylistHandlers { var cb = s.getCriteriaBuilder(); var query = cb.createQuery(me.kavin.piped.utils.obj.db.Playlist.class); var root = query.from(me.kavin.piped.utils.obj.db.Playlist.class); - root.fetch("videos", JoinType.LEFT); + root.fetch("videos", JoinType.RIGHT); query.where(cb.equal(root.get("playlist_id"), UUID.fromString(playlistId))); var playlist = s.createQuery(query).uniqueResult();