Domanda

What is the time compltexy for SQL offset? I might think that it's not constant and that offsetting very many elements would take longer time than 0 offset, but I might also think that the time complexity is O(1) since array and RAM access times are constant. In google appengine the manual says that offsets are inefficient and that cursors should be used instead, why are offsets more inefficient when they should be in constant time? We are adviced to not use offsets when paging through large datasets and use cursors or memcache instead, is it because offset in not as efficient as O(1) which it should be if all the data can fit in RAM, then the only O(n) operation would be counting up to the n elements of the list whereas any access can be done in constant time same way that array access is in constant time?

È stato utile?

Soluzione

I have found this article very useful about this topic. It compares the performance of SQL OFFSET and SEEK for pagination. http://use-the-index-luke.com/sql/partial-results/fetch-next-page

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top