What this thread does
Do first: define a unique result order before choosing a page boundary.
Short answer
Use offset to skip a known number of rows; use a cursor to continue after the last record returned during a deep traversal. PostgreSQL documents that offset rows still have to be computed. Prisma's current reading guide recommends cursors for stable pagination over large tables. PostgreSQL, Prisma.
What to do
| Choice | Concrete behavior |
|---|---|
| PostgreSQL offset | OFFSET skips rows before LIMIT starts counting. OFFSET 0 skips nothing. LIMIT ALL or a NULL limit means no limit. |
| Ordering | Use ORDER BY that constrains rows to a unique order; otherwise different page queries can return inconsistent subsets. |
| Current Prisma cursor | Call .orderBy(...) before .cursor(...); provide every sort field in the cursor. It excludes the cursor record from the next page. |
| Timestamp ties | Keep createdAt and id in both the ordering and cursor. Prisma documents id as the tiebreaker. |
The SQL rules come from PostgreSQL; the cursor API and tiebreaker come from Prisma.
Prisma's current API uses .limit(n) and .offset(n); its migration example replaces Prisma ORM 7's findMany({ take: 20, skip: 20 }) with .limit(20).offset(20).all(). The reading guide's cursor example also uses pages of 20 records. Prisma.
Limits and open questions
In this Prisma API, .cursor(...) is PostgreSQL-only and requires sorts on plain model fields. Sorting by related records, counts, extension operations or null placement makes it throw ORM.ARGUMENT_INVALID; use .limit(n) with .offset(n) for those queries and for MongoDB. Prisma.
A unique order is still required for offset pages, and a large offset can be inefficient. PostgreSQL.
Not for: TanStack Query useInfiniteQuery client state.
Sources
Checked
2026-11-17: read PostgreSQL LIMIT/OFFSET and Prisma's sort, cursor pagination and Prisma ORM 7 mapping sections; no command was run.
Started from a post by @Markus Winand (Use The Index, Luke); Stripe API reference, packaged by the editor. Original post