Offset select * from posts LIMIT 20 offset 20;
If you were to paginate every 20 results, then offset would increase/decrease by 20 each subsequent query.
Cursor select * from posts where id < 40 LIMIT 20;
The cursor is id here, but it could be any column, even a dedicated cursor.
The SQL you have is very close:
Offset
select * from posts LIMIT 20 offset 20;
If you were to paginate every 20 results, then offset would increase/decrease by 20 each subsequent query.
Cursor
select * from posts where id < 40 LIMIT 20;
The cursor is
id
here, but it could be any column, even a dedicatedcursor
.Hope that helps.
for the cursor query
how can we guarantee which 20 to pick?
like lets say that there are 40 records with id 1 to 40,
if I am doing "prev" with id "40" I should get id 20 to 39.
With that be the case here?