0

this What is the cost difference between paging with a cursor or using offset? question lead me to the question, how do I actually build a Pager with Cursor/Offset/Limit in AppEngine (Python 2.7).

I know how to do that with MySQL and PHP easily => LIMIT x,y

Thank you very much

Community
  • 1
  • 1
Julius F
  • 3,434
  • 4
  • 29
  • 44

1 Answers1

3

Using cursors to do paging is a different approach to solving the problem than using queries with offsets. As Nick noted in the answer to the question that you linked, using offset incurs a possibly heavy expense of datastore operations. Cursors circumvent that cost, and they are the better solution to the problem.

Fortunately, this is a wheel that does not need to be reinvented. Ben Davies has created a PagedQuery class that you can use directly in your AppEngine/Python code and it does virtually all of the work for you.

I use it in my blogging software, and I can't recommend it highly enough.

Adam Crossland
  • 14,198
  • 3
  • 44
  • 54