Why You Should Avoid Offset in Your DB Queries
We often use offset or skip in our database queries to fetch paginated data. This helps in implementing server-side pagination where it is not convenient to fetch all the data at once for performance reasons.
Real-world use cases for this might be wh...
rrawat.hashnode.dev2 min read
When paginating the results of a query in Oracle REST APIs...we don't actually do that.
We take the query...and rewrite it to have the 'page' returned as a singular resultset.
So each time the user/app follows the link for the next or previous page, the query is executed again.
So instead of
SELECT * FROM my_tableWe run
SELECT * FROM ( SELECT Q_.*, ROW_NUMBER() OVER( ORDER BY 1 ) RN___ FROM( SELECT * FROM my_table ) Q_ ) WHERE RN___ BETWEEN :1 AND :2The API dev can of course override this and build their own logic, or even disable paging...