내 질문을 선택이 하나와 유사한 : Need a row count after SELECT statement: what's the optimal SQL approach?총 행 수 + 제한으로
하지만 쿼리에서 행의 총을 얻을하고 그래서 사용할 수 없습니다 매김을 만드는 데 제한을 사용하려면 반환되는 행
select a.*, (select count(1) from (select * from res_groups) e) total
from (select * from res_groups) a limit 10 offset 10;
아니면이 쉽게 접근 방식을 사용하여 두 개의 쿼리를 만들 수 :
select * from res_groups limit 10;
select count(*) from res_groups;
하는 첫 번째 쿼리가 performatic됩니다
select * from res_groups
나는이에 합격 : 간단한 쿼리에서 ? res_groups의 쿼리가 두 번 실행됩니다.
다른 방법이 있습니까? PS : 이제
WITH a AS (select *, count(*) over (range unbounded preceding)
FROM resgroups)
SELECT * from a order by foo limit 10 offset 10;
, 당신이 그것을 당신처럼 보이기 때문에 비록 두 개의 쿼리에이 깰 떨어져 실제로 더 나은 생각 : 나는 포스트 그레스를 사용하고, 나는 MySQL은 FOUND_ROWS()