locked
Best way to do pagination with a simple URL like ?page=2 RRS feed

  • Question

  • I think I already know the answer to my question, but hopefully someone knows a better way.  I understand the concept of continuation tokens, however lets say you had a blog, and maybe for SEO purposes or just sending a link to someone else (so new browser, no session) you need a URL like myblog.com/?page=10 

    I am guessing that they only real way to do this is grabbing the first 10 pages of data and then just using the last pages worth for display.

    This could be alot of data crunching, say it was a forum and you had a thread with 1000 posts, showing 10 at a time.  The most form software allows you to jump to pages at will, so if the user clicked give me page 90, you can see where I am going :)

    Is there a better way?

    Friday, February 11, 2011 5:23 AM

Answers

  • Hi,

    One option could be to maintain an entity table with the start point of each page. With the example of posts, the first post creates a new entity in that table pointing at the keys of the first post, the 11th post will create a second entry. You will need to have logic on the inserts to handle this, but the queries for pages should be more optimal.

    If you use RowKey as page number it shuld be queryable from a simple URI.

    Regards,

    Alan


    http://www.CloudCasts.net - Community Webcasts Powered by Azure
    • Marked as answer by Mog Liang Friday, February 18, 2011 9:58 AM
    Friday, February 11, 2011 7:54 AM

All replies

  • Hi,

    One option could be to maintain an entity table with the start point of each page. With the example of posts, the first post creates a new entity in that table pointing at the keys of the first post, the 11th post will create a second entry. You will need to have logic on the inserts to handle this, but the queries for pages should be more optimal.

    If you use RowKey as page number it shuld be queryable from a simple URI.

    Regards,

    Alan


    http://www.CloudCasts.net - Community Webcasts Powered by Azure
    • Marked as answer by Mog Liang Friday, February 18, 2011 9:58 AM
    Friday, February 11, 2011 7:54 AM
  • Scott Desnnore has a post showing how to page across data using continuation tokens.

    Jim O'Neil also has a post showing asynchronous table storage pagination.

    Friday, February 11, 2011 4:04 PM
    Answerer
  • One problem I see with keeping a separate table to keep the start points of each page is that when your users do delete posts you have to keep everything in sync.  We faced a similar situation in our blog app, after searching around we decided to go with the twitter/facebook way of having a "Load more" button at the bottom of the blog index page to ajax fetch more posts and append them onto the same page; the same thing for a blog post page's comments.  Because compared with the index page of a blog, it is not as likely for visitors to browse to, say, page 10 of your blog that often.  But it really depends on your biz requirement, our approach may not work for you.
    Monday, February 14, 2011 3:54 PM