Quellcode durchsuchen

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 vor 4 Wochen
Ursprung
Commit
ab94f42ad1
1 geänderte Dateien mit 2 neuen und 2 gelöschten Zeilen
  1. 2 2
      internal/storage/icon.go

+ 2 - 2
internal/storage/icon.go

@@ -78,8 +78,8 @@ func (s *Storage) IconByFeedID(userID, feedID int64) (*model.Icon, error) {
 			icons.content,
 			icons.content,
 			icons.external_id
 			icons.external_id
 		FROM icons
 		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
 		WHERE
 			feeds.user_id=$1 AND feeds.id=$2
 			feeds.user_id=$1 AND feeds.id=$2
 		LIMIT 1
 		LIMIT 1