Why GitHub Blocks Search Results Beyond Page 10: The Deep Pagination Problem
GitHub's Search API deliberately returns a 422 error when users request results beyond the first 1,000 entries, blocking access to page 11 and beyond with 100 results per page. The restriction exists because of a fundamental database limitation: SQL's OFFSET clause cannot jump directly to a position in a B-tree index and must scan and discard every preceding row one by one. This means fetching page 50,000 of a 20-results-per-page query forces the database to walk through nearly a million rows before returning any data, making query cost proportional to the offset rather than the page size. A real-world test on a 5-million-row PostgreSQL table confirmed the issue, with an OFFSET of 999,980 causing the engine to scan exactly one million rows before delivering just 20 results. GitHub's hard cap is a deliberate safeguard against this performance problem, which can silently affect any application using offset-based pagination on large datasets.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in