# 1 (팔로우한 사람들의 게시글)
following_posts = self.get_feed_by_follow_relation(user, True).filter(filters).order_by("-id")
# 2 (팔로우 하지 않은 사람들의 게시글)
unfollowing_posts = self.get_feed_by_follow_relation(user, False).filter(filters).order_by("-id")
각각 쿼리(총 2번)해서 메모리에서 list, chain 으로 합치는 방법
Method: GET | Path: /records/post/ | Duration: 3.2465s | DB Queries: 16 | Status: 200
posts = list(chain(following_posts, unfollowing_posts))
db에서 union으로 합치고 중복확인 하지않고 한번의 쿼리로 가져오는 방법
Method: GET | Path: /records/post/ | Duration: 3.2377s | DB Queries: 15 | Status: 200
posts = following_posts.union(unfollowing_posts, all=True)
물론 쿼리 복잡도가 올라가 데이터의 크기가 크다면 DB 부하가 더 커질 여지가 있다.