Upcoming Drillbridge features, part 1: relational paging

As of Drillbridge 1.3.0, paging is now supported. More specifically, tokens
that help write paging queries in SQL are provided – paging is not done
automatically. The reason that automatic paging is not supported is that while
this approach ostenisbly means writing a bit of SQL code to perform the paging, it’s
the most flexible and most performant.

If paging is turned on for a given report, then when that report is built, in
addition to the normal Point-of-View parameters that are made available to the
query, there will be three additional parameters:

  • PAGE
  • ROWS_PER_PAGE
  • OFFSET

Drillbridge will start the PAGE variable off with 1. This token can be used like any other token. The ROWS_PER_PAGE variable can also be used like any other token and can be configured on the report itself. Typical values might be 20, 50, 100, 500, or 1,000.

The OFFSET variable is not specified in the report request, it is calculated as a convenience variable to be used in queries. OFFSET is provided since in some SQL dialects, the total number of rows to skip is needed rather than a page or other option. The formula for OFFSET is:

(page - 1) * rowsPerPage

For example, if a report is meant to page on every 20 rows, meaning that page 1 is rows 1-20, page 2 is rows 21-40, and so on, the following would be true on page 2:

  • PAGE = 2
  • ROWS_PER_PAGE = 20
  • OFFSET = (2 – 1) * 20 = 20

If your data source was a MySQL database for example, then a paging query to this technology might be this:

SELECT column FROM table LIMIT 10 OFFSET 10

As you can see, we will want to plug in the ROWS_PER_PAGE for the 10 after LIMIT, and then the OFFSET for the 10 after the OFFSET keyword. Different SQL technologies have different ways of paging data (some are more complex than others…) but this one is straightforward, thankfully.

Just plug in the given variables like any other, turn on paging in the report, and presto, instant paging – with good performance.

Next week I’ll talk about some of the other cool features coming soon…

Leave a Reply

Your email address will not be published.