Created
December 23, 2009 13:02
-
-
Save ssokolow/262503 to your computer and use it in GitHub Desktop.
Reasonably efficient pagination without OFFSET (SQLite version)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Reasonably efficient pagination without OFFSET | |
-- SQLite version (Adapted from MS SQL syntax) | |
-- Source: http://www.phpbuilder.com/board/showpost.php?p=10376515&postcount=6 | |
SELECT foo, bar, baz, quux FROM table | |
WHERE oid NOT IN ( SELECT oid FROM table | |
ORDER BY title ASC LIMIT 50 ) | |
ORDER BY title ASC LIMIT 10 |
Gotta admit...this is way cool 😎
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah. It's basically a workaround for some databases' query planners not being very smart about
OFFSET
.