Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Paging Large Result Sets

 
Mike London
Ranch Hand
Posts: 1192
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

If you have a large XML (thousands of rows) Response from a Spring Web Service, how is the best way to implement paging or is paging the best way to approach this issue? The pipe between the client and service only allows so much data so we need to handle this situation somehow.

Should there be some unique ID sent from the client with the Request and follow up Requests (incremented somehow) so you know which chunk of Response data to send back in subsequent Requests?

Just wondering how this should best be done..

Thanks in advance for any suggestions.

mike
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64830
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I frequently send 4 items of metadata with each request/response that could be paged:
  • the property (column) to sort on
  • the sort order
  • the page size
  • the page number
  •  
    Mike London
    Ranch Hand
    Posts: 1192
    4
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Bear Bibeault wrote:I frequently send 4 items of metadata with each request/response that could be paged:
  • the property (column) to sort on
  • the sort order
  • the page size
  • the page number


  • Hey Bear,

    Good to hear from you.

    But, what about a "requesterId" or something so you could keep all the paging progress in sync for the various Requesting clients?

    And these metadata values would have to be attributes or elements in the Request method's XSD definition, right (Spring WS: XSD only)?

    - mike
     
    Bear Bibeault
    Author and ninkuma
    Marshal
    Pie
    Posts: 64830
    86
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Any other filters are outside the scope of this metadata.

    And sorry, I have no idea about the XML. I work exclusively with JSON.
     
    Mike London
    Ranch Hand
    Posts: 1192
    4
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Bear Bibeault wrote:Any other filters are outside the scope of this metadata.

    And sorry, I have no idea about the XML. I work exclusively with JSON.


    JSON, ahhhhhh......

    In any case, it seems that we'd just accept the information about how many rows to send back (and possibly some of your other metadata) in the Request and then do the SQL for that Response. I was thinking that the entire request would be cached on the server and need to coordinate future requests with multiple clients, but that doesn't make sense with hundreds of potential simultaneous clients.

    Appreciate your reply.

    mike
     
    Bear Bibeault
    Author and ninkuma
    Marshal
    Pie
    Posts: 64830
    86
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I never do any state on the server. That violates RESTful principles.

    The metadata is sent with the request, and is sent back to the client in the response (along with other metadata such as counts). It's the responsibility of the client to keep track of things.
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic