I observed a strange behaviour with ROWNUM in Oracle with static tables. I am trying pagination with query like below
select * from (
select the_data,rownum as seqn from the_table
) where seqn <= somenumber and seqn >= othernumber
However when I execute query multiple times I observe that the rownum value returned is not unique for a row ie if a row appears at rownum 25 for the first time it appears at rownum 125 for second execution
This issue does not appear if I do a order by like,
select * from (
select the_data,rownum as seqn from the_table order by column3
) where seqn <= somenumber and seqn >= othernumber
However order by decreases performance. Is this normal or is there any other way to improve performance.