Stay organized with collections
Save and categorize content based on your preferences.
Manage workload reservations
The BigQuery Reservation API lets you purchase dedicated slots (called
commitments), create pools
of slots (called reservations),
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 named prod and assign your production workloads to this
reservation. For more information, see
Understand reservations.
Create reservations
Required permissions
To create a reservation, you need the following Identity and Access Management (IAM)
permission:
bigquery.reservations.create on the
administration project
that maintains ownership of the commitments.
Each of the following predefined IAM roles includes this
permission:
To update the reservation-based fairness on a project, you need the bigquery.config.update
permission on the project
that maintains ownership of the reservations. The predefined BigQuery Admin
role includes this permission.
In the Max reservation size selector list, select the maximum reservation size.
Optional: In the Baseline slots field, enter the number of baseline
slots for the reservation.
The number of available autoscaling slots is determined by
subtracting the Baseline slots value from the Max 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, see
Using reservations with baseline and autoscaling
slots.
To disable idle slot sharing
and use only the specified slot capacity, click the Ignore idle slots
toggle.
To expand the Advanced settings section, click the
expand_moreexpander arrow.
Optional: To set default project scheduling policies for the
reservation, configure the following options:
Project Concurrency: Limit the concurrency of jobs running for
any particular project within this reservation.
Project Max Slots: Limit the slot consumption of queries running
for any particular project within this reservation.
In the How to use idle slots? list, select the configuration option.
Most predictable: Consumes baseline slots first, then idle slots,
and finally autoscaling slots up to the specified maximum number of
slots.
Less predictable: Consumes baseline and idle slots only, up to the
maximum number of slots. No autoscaling slots are used.
Most variable: All available idle slots are used to scale above
baseline. Then, autoscaling slots are used, up to the difference between
the maximum and baseline. This can cause the reservation to
exceed the specified maximum number of slots.
The breakdown of slots is displayed in the Cost estimate table.
A summary of the reservation is displayed in the Capacity summary table.
Click Save.
The new reservation is visible in the Slot reservations tab.
bq
To create a predictable reservation, use the bq mk command with the --reservation
flag and set the value of max_slots and scaling_mode:
LOCATION: the
location of the reservation. If you select a
BigQuery 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, see Introduction to BigQuery editions.
MAXIMUM_NUMBER_OF_SLOTS: the maximum number of slots the reservation can consume. This value must be configured with the --scaling_mode flag.
SCALING_MODE: the scaling mode of the reservation. The options are ALL_SLOTS, IDLE_SLOTS_ONLY, or AUTOSCALE_ONLY. This value must be configured with the max_slots flag. This value must be aligned with ignore_idle_slots flag. For details, see Reservation predictability.
For information about the --ignore_idle_slots flag, see
Idle slots. The default
value is false.
ADMIN_PROJECT_ID: the project ID of the
administration project
that owns the reservation resource.
LOCATION: the
location of the reservation. If you select a
BigQuery 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 the slot_capacity option and the standard edition option 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, see Introduction to BigQuery editions.
IGNORE_IDLE_SLOTS: whether the reservation uses Idle slots or not. The default value is false.
MAX_NUMBER_OF_SLOTS: the maximum number of slots the reservation can consume. This value must be configured with scaling_mode option.
SCALING_MODE: the scaling mode of the reservation. The options are ALL_SLOTS, IDLE_SLOTS_ONLY, or AUTOSCALE_ONLY. This value must be configured with the max_slots option. This value must be aligned with ignore_idle_slots option. For details, see Reservation predictability.
MAX_SLOTS_PER_PROJECT: the default limit on
the slot consumption of queries running for each project assigned to
the reservation.
MAX_CONCURRENCY_PER_PROJECT: the default
limit on the number of simultaneous queries admitted for each project
assigned to the reservation.
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 a root module).
In Cloud Shell, create a directory and a new
file within that directory. The filename must have the
.tf extension—for example main.tf. In this
tutorial, the file is referred to as main.tf.
mkdir DIRECTORY && cd DIRECTORY && 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 created main.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 -upgrade
option:
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 entering yes
at the prompt:
terraform apply
Wait until Terraform displays the "Apply complete!" message.
Open your Google Cloud project to 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.
To enable per-second billing with no minimum duration for a reservation, enable
it at the administration-project level by listing the reservation in the
preflight_fluid_autoscaling_reservations option. Changes to the
BigQuery fluid scaling configuration can take a few minutes to propagate.
For reservations using managed disaster recovery,
you must enable BigQuery fluid scaling in both the primary and secondary
regions to ensure per-second billing after a failover.
To update the list of reservations with BigQuery fluid scaling, modify the list in the
preflight_fluid_autoscaling_reservations option. To disable the feature for all reservations in a region, set the preflight_fluid_autoscaling_reservations option to NULL.
ADMIN_PROJECT_ID: the project ID of the
administration project
that owns the reservation resource
LOCATION: the
location of the reservation, for example europe-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_slots flag controls whether queries running in a reservation
can use idle slots from other reservations. For more information, see
Idle slots. You can update this
configuration on an existing reservation.
To update a reservation, use the bq update command with the --reservation
flag. The following example sets --ignore_idle_slots to true,
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 the idle slots setting
for a reservation, do the following:
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.delete on the
administration project
that maintains ownership of the commitments.
Each of the following predefined IAM roles includes this
permission:
You can control which users have access to specific
reservations. For a user to override a reservation on their query, they must
have the reservations.use permission 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 the
Resource Editor (roles/bigquery.resourceEditor) IAM role on the reservation resource.
For more information about granting roles, see Manage access to projects, folders, and organizations.
This predefined role contains the
reservations.use
permission,
which is required to
specify a particular reservation for your job.
To manage access to a specific reservation resource, use the bq
set-iam-policy
command.
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 an IAM condition
to allow access to the reservation resources when the specified conditions are
met.
To control access to reservations, do one of the following:
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 the
Reservation Editor (roles/bigquery.reservationEditor) IAM role on the reservation resource.
For more information about granting roles, see Manage access to projects, folders, and organizations.
A reservation group can only be deleted if it does not contain any member reservations. Reservation groups are not automatically deleted when the last member reservation is deleted. You must manually delete the reservation group after removing all member reservations.
You might encounter the following errors when creating or updating a reservation:
Error: Max reservation size can only be configured in multiples of 50, except when covered by excess commitments.
Error: Baseline slots can only be configured in multiples of 50, except when covered by excess commitments.
Slots always autoscale to a multiple of 50. Scaling up is based on actual usage, and is rounded up to the nearest 50 slot increment. When there is no commitment or if the commitment cannot cover the increases, the baseline and autoscaling slots can only be increased in multiples of 50.
If reservation size - baseline slots isn't a multiple of 50, then the reservation can't scale up to the maximum reservation size, resulting in this error.
Resolution:
Purchase more capacity commitments to cover the slot increases.
Choose baseline and max slots that are increments of 50.
[[["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 2026-07-17 UTC."],[],[]]