I'm trying to achieve pagination of a large dataset. I figured this might work
select asortyment.nazwa as NAZWA,
parpoz.ilosc as ILOSC,
parpoz.cenabrutto as CENA,
parnagl.data as DATA
from parnagl
inner join ParPoz on ParPoz.ParNaglID=ParNagl.ParNaglID
inner join asortyment on asortyment.poztowid=parpoz.poztowid
inner join grupapt on asortyment.grupaptid=grupapt.grupaptid
WHERE ROWNUM <= 10
This takes 12 seconds to perform. On the other hand, if I specify date range using WHERE clause, it only takes 50ms... Is there any way I could optimise this?
The database is Oracle 11g.