Skip to main content
Version: v2.x

BigQuery: Paginate query results

The limit & offset arguments

The operators limit and offset are used for pagination.

limit specifies the number of rows to retain from the result set and offset determines which slice to retain from the results.

You can see the complete specification of the limit and offset arguments in the API reference.

The following are examples of different pagination scenarios:

Limit results

Example: Fetch the first 5 authors from the list of all authors:

GraphiQL
Query Variables
Request Headers
Note

The query field will be of the format <dataset_name>_<table_name>.

Limit results from an offset

Example: Fetch 5 authors from the list of all authors, starting with the 6th one:

GraphiQL
Query Variables
Request Headers

Limit results in a nested object

Example: Fetch a list of authors and a list of their first 2 articles:

GraphiQL
Query Variables
Request Headers

Fetch limited results along with data aggregated over all results (e.g. total count) in the same query

Sometimes, some aggregated information on all the data is required along with a subset of data.

E.g. the total count of results can be returned along with a page of results. The count can then be used to calculate the number of pages based on the limit that is set.

Example: Fetch a list of articles where a certain condition is true and get their count. Then limit the number of articles to return.

GraphiQL
Query Variables
Request Headers