The BigQuery Reservation API lets you purchase dedicated slots (calledcommitments), create pools
of slots (calledreservations),
and assign projects, folders, and organizations to those reservations.
Reservations allow you to assign a dedicated number of slots
to a workload. For example, you might not want
a production workload to compete with test workloads for slots. You could
create a reservation namedprodand assign your production workloads to this
reservation. For more information, seeReservations.
Create reservations
Required permissions
To create a reservation, you need the following Identity and Access Management (IAM)
permission:
bigquery.reservations.createon theadministration projectthat maintains ownership of the commitments.
Each of the following predefined IAM roles includes this
permission:
In theReservation namefield, enter a name for the reservation.
In theLocationlist, select the location. If you select aBigQuery Omni
location, your edition
option is limited to the Enterprise edition.
In theEditionlist, select the edition. BigQuery
edition features such as autoscaling are only available within an
edition. For more information, seeIntroduction to BigQuery editions.
In theMax reservation size selectorlist, select the maximum reservation size.
Optional: In theBaseline slotsfield, enter the number of baseline
slots for the reservation.
The number of available autoscaling slots is determined by
subtracting theBaseline slotsvalue from theMax reservation
size. For example, if you create a reservation with 100 baseline
slots and a max reservation size of 400, your reservation has 300
autoscaling slots. For more information about baseline slots, seeUsing reservations with baseline and autoscaling
slots.
To disableidle slot sharingand use only the specified slot capacity, click theIgnore idle slotstoggle.
To expand theAdvanced settingssection, click theexpand_moreexpander arrow.
Optional: To set the target job concurrency, click theOverride
automatic target job concurrencytoggle to on and enter theTarget
Job Concurrency.
The breakdown of slots is displayed in theCost estimatetable.
A summary of the reservation is displayed in theCapacity summarytable.
ClickSave.
The new reservation is visible in theSlot reservationstab.
ADMIN_PROJECT_ID: the project ID of theadministration projectthat owns the reservation resource
LOCATION: thelocationof the reservation. If you select aBigQuery Omni
location, your edition
option is limited to the Enterprise edition.
RESERVATION_NAME: the name of the
reservation
The name can contain only lowercase alphanumeric characters or dashes, must start with a letter and must not end with a dash, and the maximum length is 64 characters.
NUMBER_OF_BASELINE_SLOTS: the number baseline of slots to
allocate to the reservation. You cannot set theslot_capacityoption and theeditionoption in the same reservation.
EDITION: the edition of the reservation. Assigning a reservation to an edition comes with feature and pricing changes. For more information, seeIntroduction to BigQuery editions.
NUMBER_OF_AUTOSCALING_SLOTS: the number of autoscaling slots assigned to the reservation. This is equal to the value of the max reservation size minus the number of baseline slots.
LOCATION: thelocationof the reservation. If you select aBigQuery Omni
location, your edition
option is limited to the Enterprise edition.
NUMBER_OF_BASELINE_SLOTS: the number of baseline slots to
allocate to the reservation
RESERVATION_NAME: the name of the reservation. The name can contain only lowercase alphanumeric characters or dashes, must start with a letter and must not end with a dash, and the maximum length is 64 characters.
EDITION: the edition of the reservation. Assigning a reservation to an edition comes with feature and pricing changes. For more information, seeIntroduction to BigQuery editions.
NUMBER_OF_AUTOSCALING_SLOTS: the number of autoscaling slots assigned to the reservation. This is equal to the value of the max reservation size minus the number of baseline slots. This can't be configured with either the--max_slotsor--scaling_modeflags.
MAXIMUM_NUMBER_OF_SLOTS: the maximum number of slots the reservation can consume. This value must be configured with the--scaling_modeflag (Preview).
SCALING_MODE: the scaling mode of the reservation. The options areALL_SLOTS,IDLE_SLOTS_ONLY, orAUTOSCALE_ONLY. This value must be configured with the--scaling_modeflag (Preview).
For information about the--ignore_idle_slotsflag, seeIdle slots. The default
value isfalse.
The following example creates a reservation namedmy-reservation:
resource "google_bigquery_reservation" "default" {
name = "my-reservation"
location = "us-central1"
slot_capacity = 100
edition = "ENTERPRISE"
ignore_idle_slots = false # Use idle slots from other reservations
concurrency = 0 # Automatically adjust query concurrency based on available resources
autoscale {
max_slots = 200 # Allow the reservation to scale up to 300 slots (slot_capacity + max_slots) if needed
}
}
To apply your Terraform configuration in a Google Cloud project, complete the steps in the
following sections.
Set the default Google Cloud project
where you want to apply your Terraform configurations.
You only need to run this command once per project, and you can run it in any directory.
export GOOGLE_CLOUD_PROJECT=PROJECT_ID
Environment variables are overridden if you set explicit values in the Terraform
configuration file.
Prepare the directory
Each Terraform configuration file must have its own directory (also
called aroot module).
InCloud Shell, create a directory and a new
file within that directory. The filename must have the.tfextension—for examplemain.tf. In this
tutorial, the file is referred to asmain.tf.
mkdirDIRECTORY&& cdDIRECTORY&& touch main.tf
If you are following a tutorial, you can copy the sample code in each section or step.
Copy the sample code into the newly createdmain.tf.
Optionally, copy the code from GitHub. This is recommended
when the Terraform snippet is part of an end-to-end solution.
Review and modify the sample parameters to apply to your environment.
Save your changes.
Initialize Terraform. You only need to do this once per directory.
terraform init
Optionally, to use the latest Google provider version, include the-upgradeoption:
terraform init -upgrade
Apply the changes
Review the configuration and verify that the resources that Terraform is going to create or
update match your expectations:
terraform plan
Make corrections to the configuration as necessary.
Apply the Terraform configuration by running the following command and enteringyesat the prompt:
terraform apply
Wait until Terraform displays the "Apply complete!" message.
Open your Google Cloud projectto view
the results. In the Google Cloud console, navigate to your resources in the UI to make sure
that Terraform has created or updated them.
# TODO(developer): Set project_id to the project ID containing the# reservation.project_id="your-project-id"# TODO(developer): Set location to the location of the reservation.# See: https://cloud.google.com/bigquery/docs/locations for a list of# available locations.location="US"# TODO(developer): Set reservation_id to a unique ID of the reservation.reservation_id="sample-reservation"# TODO(developer): Set slot_capicity to the number of slots in the# reservation.slot_capacity=100# TODO(developer): Choose a transport to use. Either 'grpc' or 'rest'transport="grpc"# ...fromgoogle.cloud.bigquery_reservation_v1.servicesimportreservation_servicefromgoogle.cloud.bigquery_reservation_v1.typesimport(reservationasreservation_types,)reservation_client=reservation_service.ReservationServiceClient(transport=transport)parent=reservation_client.common_location_path(project_id,location)reservation=reservation_types.Reservation(slot_capacity=slot_capacity)reservation=reservation_client.create_reservation(parent=parent,reservation=reservation,reservation_id=reservation_id,)print(f"Created reservation:{reservation.name}")
To update the reservation-based fairness on a project, you need thebigquery.config.updatepermission on theprojectthat maintains ownership of the reservations. The predefinedBigQuery Adminrole includes this permission.
In the navigation panel, go to theCapacity managementsection, and
then clickCreate reservation.
In theReservation namefield, enter a name for the reservation.
In theLocationlist, select the location. If you select aBigQuery Omni
location, your edition
option is limited to the Enterprise edition.
In theEditionlist, select the edition. Autoscaling is only
available within an edition. For more information, seeUnderstand BigQuery
editions.
In theMax reservation size selectorlist, select the maximum reservation size.
Optional: In theBaseline slotsfield, enter the number of baseline
slots for the reservation.
The number of available autoscaling slots is determined by
subtracting theBaseline slotsvalue from theMax reservation
size. For example, if you create a reservation with 100 baseline
slots and a max reservation size of 400, your reservation has 300
autoscaling slots. For more information about baseline slots, seeUsing reservations with baseline and autoscaling
slots.
To disableidle slot sharingand use only the specified slot capacity, click theIgnore idle slotstoggle.
To expand theAdvanced settingssection, click theexpand_moreexpander arrow.
In theHow to use idle slots?list, select the configuration option.
The breakdown of slots is displayed in theCost estimatetable.
A summary of the reservation is displayed in theCapacity summarytable.
ClickSave.
The new reservation is visible in theSlot reservationstab.
bq
To create a predictable reservation, use thebq mkcommand with the--reservationflag and set the value ofmax_slotsandscaling_mode:
LOCATION: thelocationof the reservation. If you select aBigQuery Omni
location, your edition
option is limited to the Enterprise edition.
NUMBER_OF_BASELINE_SLOTS: the number of baseline slots to
allocate to the reservation
RESERVATION_NAME: the name of the reservation
EDITION: the edition of the reservation. Assigning a reservation to an edition comes with feature and pricing changes. For more information, seeIntroduction to BigQuery editions.
MAXIMUM_NUMBER_OF_SLOTS: the maximum number of slots the reservation can consume. This value must be configured with the--scaling_modeflag.
SCALING_MODE:SCALING_MODE: the scaling mode of the reservation. The options areALL_SLOTS,IDLE_SLOTS_ONLY, orAUTOSCALE_ONLY. This value must be configured with themax_slotsflag. This value must be aligned withignore_idle_slotsflag. For details, seeReservation predictability.
For information about the--ignore_idle_slotsflag, seeIdle slots. The default
value isfalse.
ADMIN_PROJECT_ID: the project ID of theadministration projectthat owns the reservation resource.
LOCATION: thelocationof the reservation. If you select aBigQuery Omni
location, your edition
option is limited to the Enterprise edition.
RESERVATION_NAME: the name of the
reservation.The name can contain only lowercase alphanumeric characters or dashes, must start with a letter and must not end with a dash, and the maximum length is 64 characters.
NUMBER_OF_BASELINE_SLOTS: the number baseline of slots to
allocate to the reservation. You cannot set theslot_capacityoption and theeditionoption in the same reservation.
EDITION: the edition of the reservation. Assigning a reservation to an edition comes with feature and pricing changes. For more information, seeIntroduction to BigQuery editions.
IGNORE_IDLE_SLOTS: whether the reservation usesIdle slotsor not. The default value isfalse.
MAX_NUMBER_OF_SLOTS: the maximum number of slots the reservation can consume. This value must be configured withscaling_modeoption.
SCALING_MODE: the scaling mode of the reservation. The options areALL_SLOTS,IDLE_SLOTS_ONLY, orAUTOSCALE_ONLY. This value must be configured with themax_slotsoption. This value must be aligned withignore_idle_slotsoption. For details, seeReservation predictability.
ADMIN_PROJECT_ID: the project ID of theadministration projectthat owns the reservation resource
LOCATION: thelocationof the reservation, for exampleeurope-west9.
RESERVATION_NAME: the name of the
reservation. The name can contain only lowercase alphanumeric characters or dashes, must start with a letter and must not end with a dash, and the maximum length is 64 characters.
NUMBER_OF_BASELINE_SLOTS: the number of baseline slots to
allocate to the reservation.
NUMBER_OF_AUTOSCALING_SLOTS: the number of autoscaling slots assigned to the reservation. This is equal to the value of the max reservation size minus the number of baseline slots.
NUMBER_OF_BASELINE_SLOTS: the number of baseline slots to
allocate to the reservation
RESERVATION_NAME: the name of the reservation. The name can contain only lowercase alphanumeric characters or dashes, must start with a letter and must not end with a dash, and the maximum length is 64 characters.
NUMBER_OF_AUTOSCALING_SLOTS: the number of autoscaling slots assigned to the reservation. This is equal to the value of the max reservation size minus the number of baseline slots.
# TODO(developer): Set project_id to the project ID containing the# reservation.project_id="your-project-id"# TODO(developer): Set location to the location of the reservation.# See: https://cloud.google.com/bigquery/docs/locations for a list of# available locations.location="US"# TODO(developer): Set reservation_id to a unique ID of the reservation.reservation_id="sample-reservation"# TODO(developer): Set slot_capicity to the new number of slots in the# reservation.slot_capacity=50# TODO(developer): Choose a transport to use. Either 'grpc' or 'rest'transport="grpc"# ...fromgoogle.cloud.bigquery_reservation_v1.servicesimportreservation_servicefromgoogle.cloud.bigquery_reservation_v1.typesimport(reservationasreservation_types,)fromgoogle.protobufimportfield_mask_pb2reservation_client=reservation_service.ReservationServiceClient(transport=transport)reservation_name=reservation_client.reservation_path(project_id,location,reservation_id)reservation=reservation_types.Reservation(name=reservation_name,slot_capacity=slot_capacity,)field_mask=field_mask_pb2.FieldMask(paths=["slot_capacity"])reservation=reservation_client.update_reservation(reservation=reservation,update_mask=field_mask)print(f"Updated reservation:{reservation.name}")print(f"\tslot_capacity:{reservation.slot_capacity}")
Configure whether queries use idle slots
The--ignore_idle_slotsflag controls whether queries running in a reservation
can use idle slots from other reservations. For more information, seeIdle slots. You can update this
configuration on an existing reservation.
To update a reservation, use thebq updatecommand with the--reservationflag . The following example sets--ignore_idle_slotstotrue,
meaning the reservation will only use slots allocated to the reservation.
RESERVATION_NAME: the name of the reservation. The name can contain only lowercase alphanumeric characters or dashes, must start with a letter and must not end with a dash, and the maximum length is 64 characters.
List the idle slot configuration
To list theidle slotssetting
for a reservation, do the following:
TheignoreIdleSlotsfield contains the configuration setting.
Delete reservations
If you delete a reservation, any running jobs that use slots from that
reservation fail. To prevent errors, allow running jobs to complete before
you delete the reservation.
Required permissions
To delete a reservation, you need the following Identity and Access Management (IAM)
permission:
bigquery.reservations.deleteon theadministration projectthat maintains ownership of the commitments.
Each of the following predefined IAM roles includes this
permission:
RESERVATION_NAME: the name of the reservation. The name can contain only lowercase alphanumeric characters or dashes, must start with a letter and must not end with a dash, and the maximum length is 64 characters.
# TODO(developer): Set project_id to the project ID containing the# reservation.project_id="your-project-id"# TODO(developer): Set location to the location of the reservation.# See: https://cloud.google.com/bigquery/docs/locations for a list of# available locations.location="US"# TODO(developer): Set reservation_id to a unique ID of the reservation.reservation_id="sample-reservation"# TODO(developer): Choose a transport to use. Either 'grpc' or 'rest'transport="grpc"# ...fromgoogle.cloud.bigquery_reservation_v1.servicesimportreservation_servicereservation_client=reservation_service.ReservationServiceClient(transport=transport)reservation_name=reservation_client.reservation_path(project_id,location,reservation_id)reservation_client.delete_reservation(name=reservation_name)print(f"Deleted reservation:{reservation_name}")
Control access to reservations
You can control which users have access to specific
reservations. For a user to override a reservation on their query, they must
have thereservations.usepermission on that reservation.
Required permissions
To get the permission that
you need to specify a particular reservation for your job,
ask your administrator to grant you theResource Editor(roles/bigquery.resourceEditor)
IAM role on the reservation resource.
For more information about granting roles, seeManage access to projects, folders, and organizations.
This predefined role contains thereservations.usepermission,
which is required to
specify a particular reservation for your job.
To manage access to a specific reservation resource, use thebq
set-iam-policycommand.
To manage access to multiple reservation resources, use the Google Cloud console
to grant the BigQuery Resource Editor role on the project, folder, or
organization. When you grant the role, use anIAM conditionto allow access to the reservation resources when the specified conditions are
met.
To control access to reservations, do one of the following:
Console
In the Google Cloud console, you can allow access to multiple reservation
resources by using a condition.
To grant thebigquery.resourceEditorrole to a principal who has a role
on the reservation resources:
On theView by principalstab, navigate to the appropriate
principal or use theFilteroption to find the principal.
ClickeditEdit principal.
On theAssign rolespage, clickaddAdd roles.
In theSearch for rolesfield, enterbigquery.resourceEditor.
Check theBigQuery Resource Editoroption in the search results
and then clickApply.
ClickSave.
Alternatively, to grant thebigquery.resourceEditorrole to a principal
who doesn't have a role on the reservation resources:
Clickperson_addGrant Access.
On theAdd principalspage, in theNew principalsfield, enter
the principal's identifier — for example,my-user@example.com.
ClickaddAdd roles.
In theSearch for rolesfield, enterbigquery.resourceEditor.
Check theBigQuery Resource Editoroption in the search results
and then clickApply.
In theBigQuery Resource Editorbox, clickAdd condition.
On theAdd conditionpage:
Enter values in theTitleandDescriptionfields.
In theCondition builder, add your condition. For example, to
add a condition that grants the role to all reservation names that
end with/reservation1, forCondition type, chooseName,
forOperator, chooseEnds with, and forValue, enter/reservation1.
ClickSave.
ClickSave.
bq
In the bq command-line tool, you can grant access to an individual reservation resource.
You can control which reservations get priority access to idle slots by creating a reservation group.
Reservations within a reservation group will share idle slots with each other before they are available to other reservations in the project.
To get the permissions that
you need to update a particular reservation to set the reservation group,
ask your administrator to grant you theReservation Editor(roles/bigquery.reservationEditor)
IAM role on the reservation resource.
For more information about granting roles, seeManage access to projects, folders, and organizations.
RESERVATION_GROUP_NAME: the name of the reservation group. The name can contain only lowercase alphanumeric characters or dashes, must start with a letter and must not end with a dash, and the maximum length is 64 characters.
Add a reservation to a reservation group
To add a reservation to a reservation group, update thereservation_groupproperty of the reservation:
bq
To update the reservation and set the reservation group, use thebq updatecommand with the--reservationflag:
RESERVATION_GROUP_NAME: the name of the reservation group. The name can contain only lowercase alphanumeric characters or dashes, must start with a letter and must not end with a dash, and the maximum length is 64 characters.
RESERVATION_NAME: the name of the reservation. The name can contain only lowercase alphanumeric characters or dashes, must start with a letter and must not end with a dash, and the maximum length is 64 characters.
Listing the reservations that have a reservation group
To list the reservation group information for your reservations, do the following:
bq
To list the reservations and include the reservation group information, use thebq lscommand with the--reservationand--alpha=reservation_groupsflags:
bq ls \
--project_id=ADMIN_PROJECT_ID\
--location=LOCATION\
--alpha=reservation_groups \
--reservation
NUMBER_OF_BASELINE_SLOTS: the number of baseline slots to
allocate to the reservation
RESERVATION_NAME: the name of the reservation. The name can contain only lowercase alphanumeric characters or dashes, must start with a letter and must not end with a dash, and the maximum length is 64 characters.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-10-30 UTC."],[],[]]