How can I paginate a SOW Query?

Starting with AMPS 5.2, AMPS includes the skip_n option, which provides the ability to skip a set number of rows from a SOW query. Combined with the top_n and OrderBy options, this makes it easy to paginate a SOW query.

For example, if you have a set of messages like this:


You could split these into pages of 2 records (using 2 just to keep things short / simple) by submitting a query with OrderBy set to /orderId, the top_n=2 option, and a skip_n=x option. In this case, x is set to 2 * (the page number to retrieve - 1).

For example, to render the first page, the SOW query would have these modifiers:

OrderBy: /orderId
options: top_n=2,skip_n=0

To render the second page, the SOW query would include:

OrderBy: /orderId
options: top_n=2,skip_n=2

... and so on, throughout the results.

Prior to 5.2.3, pagination is only supported for a SOW query. Starting in 5.2.3, AMPS also provides support for paginated sow and subscribe. This provides paginated results during the query, and only provides messages to the subscription that would fall within the specified page of results. See the User Guide for more details.

Keywords: ROWNUM, Skip / Take, OrderBy, Pagination, top_n, TopN, skip_n, SkipN

Last updated