4
0
Эх сурвалжийг харах

refactor(storage): Use INNER JOIN instead of LEFT JOIN in IconByFeedID

The WHERE clause on feeds columns already eliminates NULL-extended rows,
making the LEFT JOINs logically equivalent to INNER JOINs. PostgreSQL's
planner is smart enough to recognize this and produces an identical
execution plan (verified with EXPLAIN ANALYZE), but using INNER JOIN
makes the intent explicit for humans like me reading the query.
jvoisin 4 долоо хоног өмнө
parent
commit
ab94f42ad1

+ 2 - 2
internal/storage/icon.go

@@ -78,8 +78,8 @@ func (s *Storage) IconByFeedID(userID, feedID int64) (*model.Icon, error) {
 			icons.content,
 			icons.external_id
 		FROM icons
-		LEFT JOIN feed_icons ON feed_icons.icon_id=icons.id
-		LEFT JOIN feeds ON feeds.id=feed_icons.feed_id
+		INNER JOIN feed_icons ON feed_icons.icon_id=icons.id
+		INNER JOIN feeds ON feeds.id=feed_icons.feed_id
 		WHERE
 			feeds.user_id=$1 AND feeds.id=$2
 		LIMIT 1