Stay organized with collectionsSave and categorize content based on your preferences.
Work with slot reservations
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 (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.
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
When you delete a reservation, any jobs that are currently executing with slots
from that reservation will fail. To prevent errors, allow running jobs to
complete before deleting 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}")
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 theReservation Editor(roles/bigquery.reservationEditor)
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.
Select a principal to grant thebigquery.resourceEditorrole to:
To grant thebigquery.resourceEditorrole to a principal who already has
other roles on the resource, find a row containing the principal, clickeditEdit principalin that row,
and clickaddAdd another role.
To grant thebigquery.resourceEditorrole to a principal who doesn't have any existing roles on the
resource, clickperson_addGrant
Access, then enter an identifier for the principal—for example,my-user@example.com.
Select thebigquery.resourceEditorrole to grant from the drop-down list.
Add aconditionto the role. For example,
you can add a condition that grants the role to all reservations that end
in/reservation1.
ClickSave. The principal is granted the role on the resource.
bq
To grant access to the reservation, use thebq
set-iam-policycommand:
[[["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-09-04 UTC."],[[["\u003cp\u003eThe BigQuery Reservation API allows for the purchase of dedicated slots, known as commitments, and the creation of slot pools called reservations, to which projects, folders, and organizations can be assigned.\u003c/p\u003e\n"],["\u003cp\u003eCreating a reservation involves defining its name, location, edition, and size, including the allocation of baseline and autoscaling slots, with the necessary IAM permissions like \u003ccode\u003ebigquery.reservations.create\u003c/code\u003e required.\u003c/p\u003e\n"],["\u003cp\u003eReservations can be managed through the Google Cloud console, SQL DDL statements, the \u003ccode\u003ebq\u003c/code\u003e command-line tool, Terraform, or Python code, allowing users to change the reservation size, configure idle slot usage, or set target job concurrency.\u003c/p\u003e\n"],["\u003cp\u003eTo update a reservation, users need IAM permission \u003ccode\u003ebigquery.reservations.update\u003c/code\u003e, and changes can include adding or removing slots, configuring idle slot usage, or adjusting baseline and autoscaling slots.\u003c/p\u003e\n"],["\u003cp\u003eDeleting a reservation requires the IAM permission \u003ccode\u003ebigquery.reservations.delete\u003c/code\u003e, and it's important to note that any running jobs using the slots from that reservation will fail, and commitments will still be charged for their remaining duration.\u003c/p\u003e\n"]]],[],null,[]]