Google is committed to advancing racial equity for Black communities. See how.

Method: projects.databases.documents.partitionQuery

Partitions a query by returning partition cursors that can be used to run the query in parallel. The returned partition cursors are split points that can be used by documents.runQuery as starting/end points for the query results.

HTTP request

POST https://firestore.googleapis.com/v1beta1/{parent=projects/*/databases/*/documents}:partitionQuery

The URL uses gRPC Transcoding syntax.

Path parameters

Parameters
parent

string

Required. The parent resource name. In the format: projects/{project_id}/databases/{database_id}/documents. Document resource names are not supported; only database resource names can be specified.

Request body

The request body contains data with the following structure:

JSON representation
{
  "partitionCount": string,
  "pageToken": string,
  "pageSize": integer,
  "structuredQuery": {
    object (StructuredQuery)
  }
}
Fields
partitionCount

string (int64 format)

The desired maximum number of partition points. The partitions may be returned across multiple pages of results. The number must be strictly positive. The actual number of partitions returned may be fewer.

For example, this may be set to one fewer than the number of parallel queries to be run, or in running a data pipeline job, one fewer than the number of workers or compute instances available.

pageToken

string

The nextPageToken value returned from a previous call to documents.partitionQuery that may be used to get an additional set of results. There are no ordering guarantees between sets of results. Thus, using multiple sets of results will require merging the different result sets.

For example, two subsequent calls using a pageToken may return:

  • cursor B, cursor M, cursor Q
  • cursor A, cursor U, cursor W

To obtain a complete result set ordered with respect to the results of the query supplied to documents.partitionQuery, the results sets should be merged: cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W

pageSize

integer

The maximum number of partitions to return in this call, subject to partitionCount.

For example, if partitionCount = 10 and pageSize = 8, the first call to documents.partitionQuery will return up to 8 partitions and a nextPageToken if more results exist. A second call to documents.partitionQuery will return up to 2 partitions, to complete the total of 10 specified in partitionCount.

structuredQuery

object (StructuredQuery)

A structured query. Filters, order bys, limits, offsets, and start/end cursors are not supported.

Response body

If successful, the response body contains data with the following structure:

The response for Firestore.PartitionQuery.

JSON representation
{
  "partitions": [
    {
      object (Cursor)
    }
  ],
  "nextPageToken": string
}
Fields
partitions[]

object (Cursor)

Partition results. Each partition is a split point that can be used by documents.runQuery as a starting or end point for the query results. The documents.runQuery requests must be made with the same query supplied to this documents.partitionQuery request. The partition cursors will be ordered according to same ordering as the results of the query supplied to documents.partitionQuery.

For example, if a documents.partitionQuery request returns partition cursors A and B, running the following three queries will return the entire result set of the original query:

  • query, endAt A
  • query, startAt A, endAt B
  • query, startAt B
nextPageToken

string

A page token that may be used to request an additional set of results, up to the number specified by partitionCount in the documents.partitionQuery request. If blank, there are no more results.

Authorization Scopes

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/datastore
  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Authentication Overview.