If your table has a primary key
, you may perform the pagination filter only on this key and in the second step select the data based on the PK.
This will allow you to use SELECT *
select * from tab
where id in (
SELECT id
FROM (SELECT id, rownum row_number
FROM (select id from tab
) A
WHERE rownum <= 10)
WHERE row_number >= 1)
You'll pay a little performance penalty, as each selected row must be additionaly accessed by the primary key index (but this will be not visible for 10 rows or so).
An other point with pagination is that you typically need to present the data in some order and not randonly as in your example.
In that case the innermost subquery will be
select id from tab order by <some column>
Here you can profit, as you need to sort only the PK and the sort key and not the whole row (but again it will be not visible for 10 rows).