Improve Django and Django REST Framework pagination for large querysets using bounded page sizes, stable ordering, indexed ordering, offset limits, keyset pagination, DRF CursorPagination, and count-query tradeoffs.
SkillScore100Maintained
Automatic
◆Coding pack
Last verified 8/16/2026
What it changes
Passed 23 of 23 test cases with the skill, and 22 of 23 without it.
Without skill96%
With skill100%
Checks it passed that the model alone missed
Recommends capped offset pagination
1 fixed22 passed either way0 still failing0 broke
Pass-rate lift
+4 pp
Tokens
-14%
Agent turns
0%
Response time
-33%
Model gemini-3.6-flashMeasured 8/16/2026v123 of 23 cases passed with skill
Tokens, turns and time describe resource use, not a dollar price.
See it in action
A test case the skill fixed. Same model, same prompt, with and without the skill.
Prompt
A customer search page in Django needs to allow users to click through pages (1, 2, 3), but querying past page 50 on our 10-million row table takes over 12 seconds. The team wants to keep page numbers visible but eliminate deep page performance degradation. What pagination strategy addresses this?
What was checked, without and with the skill
Checked
Without skill
With skill
Recommends capped offset pagination
Missed
Passed
case-04 · gemini-3.6-flash · 8/16/2026 · answers are capped and redacted
What's inside
The instructions your model reads when the skill loads.
SKILL.md40 lines2 files
Django Pagination Performance
Use this skill when a Django list view or API slows down as pages get deeper or result sets grow. Pagination is a query-design problem as much as a response-shaping problem.
Workflow
Confirm the list contract.
Is arbitrary page access required, or only next/previous?
Does the UI need a total count?
Can ordering be fixed and stable?
What page size limit is acceptable?
Measure the current query.
Capture SQL for the page query and count query.
Check ordering, indexes, and high page numbers.
Use QuerySet.explain() for deep pages.
Choose the pagination style.
Use Django Paginator for moderate result sets and arbitrary page access.
Use capped offset pagination when page numbers are useful but deep pages should be limited.
Use keyset/cursor pagination for large feeds, timelines, logs, and infinite scroll.
Use DRF CursorPagination for API next/previous navigation with stable ordering.
Make ordering deterministic.
Use a unique or nearly unique immutable ordering field.
Add a primary-key tie breaker when needed.
Ensure the index matches filters plus ordering.
See pagination-patterns.md for Django and DRF examples.
Safety Notes
Deep LIMIT/OFFSET pages can be slow because the database still walks skipped rows.
Unordered querysets produce inconsistent pages.
Cursor pagination restricts arbitrary page jumps and user-controlled ordering.
Large exact counts can dominate list latency.
Verification
Measure first page, representative deep page, count query, and insertion/deletion consistency for the chosen pagination contract.