4 ms·
Check https://use-the-index-luke.com/no-offset https://use-the-index-luke.com/no-offset as a better reference. But in most SQL databases, cursors are something
by gabetax 4y ago
Check https://use-the-index-luke.com/no-offset https://use-the-index-luke.com/no-offset as a better reference.
But in most SQL databases, cursors are something you implement and parse at the application layer, and translate to a WHERE clause on the (hopefully indexed) column you're ordering on. That turns the O(N) "OFFSET" into a O(log(n)) index seek.
- nafey 4y agoHow is a cursor different from key set in that case?
- cdash 4y agoIt's not in that case, cursors can be implemented however you want though. Its an abstraction, that prevents you from having to change the schema of the API when you change the implementation.
- lazide 4y agoMany databases have actual cursor implementations which are transactional. That means you’ll get a consistent view at the point in time you created the cursor. That said, they tend to live only as long as the db connection (with some exceptions), so yeah you need some application work to make it sane.