Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 2, 2025

Offset pagination creates O(n) load on MySQL as page depth increases. Keyset pagination uses indexed columns for O(1) performance regardless of page position.

Changes

  • New KeysetPagination component - Cursor encoding/decoding (base64 JSON), URL generation for prev/next navigation
  • New KeysetDataProvider - Replaces ActiveDataProvider, uses WHERE conditions on indexed columns instead of OFFSET
  • Updated UserController::actionIndex() - Uses KeysetDataProvider with rank as primary key column
  • Updated views/user/index.php - Manual table rendering with prev/next pagination links

How it works

Instead of:

SELECT * FROM user ORDER BY rank LIMIT 50 OFFSET 10000

Uses:

SELECT * FROM user 
WHERE rank > :lastRank OR (rank = :lastRank AND id > :lastId)
ORDER BY rank, id LIMIT 51

Cursor contains encoded {key, id} tuple for tie-breaking on non-unique sort columns.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • github.com (HTTP Only)
    • Triggering command: /usr/bin/ssh /usr/bin/ssh -o SendEnv=GIT_PROTOCOL git@github.com git-upload-pack 'jquery/jquery-dist.git' (packet block)
    • Triggering command: /usr/bin/ssh /usr/bin/ssh -o SendEnv=GIT_PROTOCOL git@github.com git-upload-pack 'RobinHerbots/Inputmask.git' (packet block)
    • Triggering command: /usr/bin/ssh /usr/bin/ssh -o SendEnv=GIT_PROTOCOL git@github.com git-upload-pack 'twbs/bootstrap.git' (packet block)
  • https://api.github.com/repos/cebe/markdown/zipball/8efb4268c90add2eee0edacf503ae71f22ccc745
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/FnhPet /usr/bin/composer install --no-dev --no-progress (http block)
  • https://api.github.com/repos/ezyang/htmlpurifier/zipball/b287d2a16aceffbf6e0295559b39662612b77fcf
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/FnhPet /usr/bin/composer install --no-dev --no-progress (http block)
  • https://api.github.com/repos/jquery/jquery-dist/zipball/c0185ab7c75aab88762c5aae780b9d83b80eda72
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/o8QfYI /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/FnhPet /usr/bin/composer install --no-dev --no-progress (http block)
  • https://api.github.com/repos/mathiasbynens/punycode.js/zipball/0fbadd6e81f3a0ce06c38998040d6db6bdfbc5c9
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/FnhPet /usr/bin/composer install --no-dev --no-progress (http block)
  • https://api.github.com/repos/php-http/discovery/zipball/82fe4c73ef3363caed49ff8dd1539ba06044910d
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/FnhPet /usr/bin/composer install --no-dev --no-progress (http block)
  • https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6d857f4d76bd4b343eac26d6b539585d2bc56493
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/FnhPet /usr/bin/composer install --no-dev --no-progress (http block)
  • https://api.github.com/repos/yiisoft/jquery-pjax/zipball/a9298d57da63d14a950f1b94366a864bc62264fb
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/FnhPet /usr/bin/composer install --no-dev --no-progress (http block)
  • https://api.github.com/repos/yiisoft/yii2-composer/zipball/b684b01ecb119c8287721def726a0e24fec2fef2
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/FnhPet /usr/bin/composer install --no-dev --no-progress (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Redo users list page using keyset / cursor pagination</issue_title>
<issue_description>Offset pagination creates too much load on MySQL.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: samdark <47294+samdark@users.noreply.github.com>
Copilot AI changed the title [WIP] Redo users list page using keyset cursor pagination Implement keyset/cursor pagination for users list page Dec 2, 2025
Copilot AI requested a review from samdark December 2, 2025 08:50
Copilot finished work on behalf of samdark December 2, 2025 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Redo users list page using keyset / cursor pagination

2 participants