Pagination

Pagination is a powerful tool to efficiently handle large datasets while maintaining optimal application performance. Athena supports pagination through the use of the LIMIT and OFFSET directives.

LIMIT

The LIMIT directive is used to restrict the number of items in the result set. By default, Athena doesn't limit your results, unless specified differently by a schema. You can utilize the LIMIT directive in your query to customize the number of items returned in a single result, allowing you to handle smaller result sets more effectively. For instance, if your application's table displays a maximum of 25 items on a single page, there is no need to transfer 1000 objects.

Syntax

The LIMIT directive must be immediately followed by an integer.

LIMIT 25

OFFSET

The OFFSET directive must be immediately followed by an integer.

OFFSET 25

The following limit/offset combinations will offer the same result:

LIMIT 25 OFFSET 10
LIMIT 25, 10

Some important points to consider:

  • Only unsigned integer values are accepted.
  • Going out of bounds does not result in an error but rather returns an empty result.

By skillfully employing pagination, you can efficiently manage and navigate through large datasets with ease using Athena's query language.