Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PostgreSQL에서는
GROUP BY절에 테이블의 기본 키(Primary Key)인m.id를 지정하면, 해당 테이블의 다른 컬럼들(m.name,m.image_urls->>0등)은 함수적 종속성(Functional Dependency) 덕분에GROUP BY절에 개별적으로 나열하지 않고도SELECT절에서 자유롭게 조회할 수 있습니다.\n\n현재 쿼리에서는m.image_urls->>0과 같은 복잡한 표현식이SELECT와GROUP BY양쪽에 중복되어 작성되어 있어, 향후 이미지 조회 로직이 변경될 때 두 곳 모두 수정해야 하는 유지보수 상의 번거로움이 있습니다.\n\n따라서SELECT절에서hr.mountain_id대신m.id를 조회하고,GROUP BY절을m.id로 단순화하면 쿼리의 가독성과 유지보수성을 크게 향상시킬 수 있습니다.References