Google App Engine : Cursor Versus Offset

Viewed 3806

Do you know which is the best approach for fetching chunks of result from a query?

1.Cursor

q = Person.all()
last_cursor = memcache.get('person_cursor')
if last_cursor:
    q.with_cursor(last_cursor)
people = q.fetch(100)
cursor = q.cursor()
memcache.set('person_cursor', cursor)

2.Offset

q = Person.all()
offset = memcache.get('offset')
if not offset:
   offset = 0
people = q.fetch(100, offset = offset)
memcache.set('offset', offset + 100)

Reading the Google documentation, it seems that Cursor does not add the overhead of a query offset.

1 Answers
Related