Database Reference
In-Depth Information
startIndex
The simplest form of pagination is index-based pagination, using the
startIndex parameter. If you got 10 results last time, you can specify that
the next request start on the 11th value. Note that startIndex can give
unexpected results when the underlying collection is changing. For example,
if you use indexed pagination to get results 1-10, then request results 11-20,
if the underlying results have changed, you might not see the values you
expect. You might skip some results or see some of the same results you saw
last time.
Because it is difficult to do a stable listing, indexed pagination is
discouraged. It is supported only on the TableData.list() operation
because often you do care about the 100th row in the table, especially when
looking at the results from a query. To demonstrate this, let's first run a
query that will generate some results to page through. This query computes
percentile distribution of word counts in Shakespeare's plays.
$
bq query \
-- destination_table=scratch.table1 \
-- max_rows=0 \
"select quantiles(word_count) from
publicdata:samples.shakespeare"
Waiting on bqjob_r8717055dd1ebad8_0000014070d5e4b8_1 …
(0s) Current
status: DONE
Once we have created the table, we can read the 100th row which is the 99th
percentile.
$ TABLES_URL=${DATASET_URL}/tables
$ TABLE_URL=${TABLES_URL}/table1
$ TABLEDATA_URL=${TABLE_URL}/data
$ curl -H "$(python auth.py)" \
"${TABLEDATA_URL}?maxResults=1&startIndex=99"
{
"kind": "bigquery#tableDataList",
"etag": "\"yBc8hy8wJ370nDaoIj0ElxNcWUg/
vk5JRNdt-25J-ICZ34R0Dqpt1Fc\"",
Search WWH ::




Custom Search