99

Concurrent visitors over the last 30 minutes. (~)

Peak concurrent visitors -
Yesterday: 0 / Today: 0

Offset and Cursor Pagination

DBSQL
2 years ago
0

Offset-based pagination, which uses an offset (start) and a limit, is the most common approach, but there is also cursor-based pagination.
When you fetch data page by page with offsets, you can get duplicated or missing items if data is added or deleted quickly in real time.
Cursor-based pagination, on the other hand, uses the position of the last item as a cursor and fetches the data that comes after it, so it is especially useful when data is added or deleted often.

SQL
1
2
3
4
5
6
7
8
9
10
11
12
13
-- Offset SELECT * FROM table_name ORDER BY created_at DESC LIMIT 10 OFFSET 10 -- Cursor SELECT * FROM table_name WHERE created_at < :cursor_created_at ORDER BY created_at DESC LIMIT 10