XML 쿼리에서 LIMIT OFFSET을 직접 지정할 수 있도록 지원#1959
Merged
1 commit merged intoJun 26, 2017
Merged
Conversation
This pull request was closed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
LIMIT에 OFFSET을 사용하는 것은 SQL의 가장 기본적인 용법 중 하나인데, 현재 XE의 XML 쿼리 문법에서는 페이징 관련 변수들을 사용하여 간접적으로 OFFSET을 지정하는 방법밖에 없습니다.
예를 들어 아래와 같은 쿼리를 실행하려면
아래와 같이 페이징을 사용해야 합니다.
게시판 모듈처럼 단순히 페이징을 하기 위한 목적이라면 이것만으로도 충분하지만, OFFSET을 직접 지정하고 싶을 때는 페이지 수를 일일이 계산해야 하기 때문에 상당히 불편합니다. 무한스크롤을 위한 AJAX 요청처럼 꼭 필요하지 않을 때도 PageHandler가 자동으로 호출되고
SELECT COUNT(*)쿼리가 발생하여 성능에 상당히 큰 악영향을 미치고요. (게시판의 글 수가 수십만 개를 넘어가면 페이징을 위한SELECT COUNT(*)쿼리가 DB 부하의 대부분을 차지합니다.)이 PR을 적용하면
<offset>태그를 사용하여 OFFSET을 직접 지정할 수 있게 됩니다.아래와 같이 쿼리를 작성하면 됩니다.
이 경우에는 PageHandler가 호출되지도 않고
SELECT COUNT(*)쿼리가 발생하지도 않습니다. 정확하게 원하는 구간(80개 건너뛰고 그 다음 20개)의 데이터만 반환됩니다.XML 쿼리 파서와 LIMIT 쿼리 생성 담당 클래스에 최소한의 기능만을 추가했으며,
<offset>태그를 사용하지 않는 기존 쿼리에는 어떤 영향도 주지 않습니다.<page>태그와<offset>태그를 함께 쓰는 경우에는<page>태그가 우선순위를 가집니다.