Skip to main content
Send feedback
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:
Each of the following predefined IAM roles includes this
permission:
BigQuery Resource Editor
BigQuery Resource Admin
For more information about IAM roles in BigQuery,
see Predefined roles and permissions
.
Create a reservation with dedicated slots
Select one of the following options:
Console
In the Google Cloud console, go to the BigQuery page.
Go to BigQuery
In the navigation menu, click Capacity management .
Click Create reservation .
In the Reservation name field, enter a name for the reservation.
In the Location list, select the location. If you select a BigQuery Omni
location
, your edition
option is limited to the Enterprise edition.
In the Edition list, select the edition. BigQuery
edition features such as autoscaling are only available within an
edition. For more information, see Introduction to BigQuery editions
.
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_more
expander arrow.
Optional: To set the target job concurrency, click the Override
automatic target job concurrency toggle to on and enter the Target
Job Concurrency .
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.
SQL
To create a reservation, use the CREATE RESERVATION
DDL statement
.
In the Google Cloud console, go to the BigQuery page.
Go to BigQuery
In the query editor, enter the following statement:
CREATE
RESERVATION
` ADMIN_PROJECT_ID
.
region
-
LOCATION
.
RESERVATION_NAME
` OPTIONS
(
slot_capacity
=
NUMBER_OF_BASELINE_SLOTS
,
edition
=
EDITION
,
autoscale_max_slots
=
NUMBER_OF_AUTOSCALING_SLOTS
);
Replace the following:
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 of baseline 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.
The supported values
are STANDARD
, ENTERPRISE
, and ENTERPRISE_PLUS
. Assigning a
reservation to an edition comes with feature and pricing changes.
For more information, see Introduction 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.
Click play_circle
Run .
For more information about how to run queries, see Run an interactive query
.
bq
To create a reservation, use the bq mk
command with the --reservation
flag:
bq mk \
--project_id= ADMIN_PROJECT_ID
\
--location= LOCATION
\
--reservation \
--slots= NUMBER_OF_BASELINE_SLOTS
\
--ignore_idle_slots=false \
--edition= EDITION
\
--autoscale_max_slots= NUMBER_OF_AUTOSCALING_SLOTS
\
--max_slots= MAXIMUM_NUMBER_OF_SLOTS
--scaling_mode= SCALING_MODE
RESERVATION_NAME
Replace the following:
ADMIN_PROJECT_ID
: the project ID
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. 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.
The supported values are STANDARD
, ENTERPRISE
, and ENTERPRISE_PLUS
. Assigning a reservation to an edition comes with
feature and pricing changes. For more information, see Introduction 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_slots
or --scaling_mode
flags.
MAXIMUM_NUMBER_OF_SLOTS
: the maximum number of slots the reservation can consume. This value must be configured with the --scaling_mode
flag ( Preview
).
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 --scaling_mode
flag ( Preview
).
For information about the --ignore_idle_slots
flag, see Idle slots
. The default
value is false
.
Use the google_bigquery_reservation
resource.
To authenticate to BigQuery, set up Application Default
Credentials. For more information, see Set up authentication for client libraries
.
The following example creates a reservation named my-reservation
:
To apply your Terraform configuration in a Google Cloud project, complete the steps in the
following sections.
Prepare Cloud Shell
Launch Cloud Shell
.
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.
Note:
Terraform samples typically assume that the required APIs are
enabled in your Google Cloud project.
Create a predictable reservation
Before you create a reservation with a maximum number of
slots
, you must
first enable reservation-based fairness
.
Enable reservation-based fairness
To enable reservation-based fairness, set the enable_reservation_based_fairness
flag
to true
.
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.
For more information about updating the default configuration of a project, see Manage configuration settings
.
ALTER
PROJECT
` PROJECT_NAME
`
SET
OPTIONS
(
`region- LOCATION
.enable_reservation_based_fairness`
=
true
);
Replace the following:
Create a predictable reservation
To create a predictable reservation with a maximum number of slots, select one
of the following options:
Console
In the Google Cloud console, go to the BigQuery page.
Go to BigQuery
In the navigation panel, go to the Capacity management section, and
then click Create reservation .
In the Reservation name field, enter a name for the reservation.
In the Location list, select the location. If you select a BigQuery Omni
location
, your edition
option is limited to the Enterprise edition.
In the Edition list, select the edition. For more information, see Understand BigQuery
editions
.
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_more
expander arrow.
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
:
bq mk \
--project_id= ADMIN_PROJECT_ID
\
--location= LOCATION
\
--reservation \
--slots= NUMBER_OF_BASELINE_SLOTS
\
--ignore_idle_slots=false \
--edition= EDITION
\
--max_slots= MAXIMUM_NUMBER_OF_SLOTS
\
--scaling_mode= SCALING_MODE
RESERVATION_NAME
Replace the following:
ADMIN_PROJECT_ID
: the project ID
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
.
SQL
To create a predictable reservation, use the CREATE RESERVATION
DDL statement
.
In the Google Cloud console, go to the BigQuery page.
Go to BigQuery
In the query editor, enter the following statement:
CREATE
RESERVATION
` ADMIN_PROJECT_ID
.
region
-
LOCATION
.
RESERVATION_NAME
` OPTIONS
(
slot_capacity
=
NUMBER_OF_BASELINE_SLOTS
,
edition
=
EDITION
,
ignore_idle_slots
=
IGNORE_IDLE_SLOTS
max_slots
=
MAX_NUMBER_OF_SLOTS
,
scaling_mode
=
SCALING_MODE
);
Replace the following:
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
.
Click play_circle
Run .
For more information about how to run queries, see Run an interactive query
.
Use the google_bigquery_reservation
resource.
To authenticate to BigQuery, set up Application Default
Credentials. For more information, see Set up authentication for client libraries
.
The following example creates a predictable reservation group named my-reservation
:
To apply your Terraform configuration in a Google Cloud project, complete the steps in the
following sections.
Prepare Cloud Shell
Launch Cloud Shell
.
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.
Note:
Terraform samples typically assume that the required APIs are
enabled in your Google Cloud project.
To learn more about predictable reservations, see Predictable
reservations
.
Update reservations
You can make the following updates to a reservation:
Change the reservation size by adding or removing slots.
Configure whether queries in this reservation use idle slots.
Change the amount of baseline or autoscaling slots allocated to a reservation.
Set the target job concurrency.
To change the edition of a reservation, first delete
the reservation, then create
a reservation with the updated edition.
Required permissions
To update a reservation, you need the following Identity and Access Management (IAM)
permission:
Each of the following predefined IAM roles includes this
permission:
BigQuery Admin
BigQuery Resource Admin
BigQuery Resource Editor
For more information about IAM roles in BigQuery,
see Predefined roles and permissions
.
Change the size of a reservation
You can add or remove slots from an existing reservation.
Console
In the Google Cloud console, go to the BigQuery page.
Go to BigQuery
In the navigation menu, click Capacity management .
Click the Slot reservations tab.
Find the reservation you want to update.
Expand the more_vert
Actions option.
Click Edit .
In the Max reservation size selector dialog, enter the max reservation size.
In the Baseline slots field, enter the number of baseline slots.
To expand the Advanced settings section, click the expand_more
expander arrow.
Optional: To set the target job concurrency, click the Override
automatic target job concurrency toggle to on and enter the Target
Job Concurrency .
Click Save .
SQL
To change the size of a reservation, use the ALTER RESERVATION SET OPTIONS
data definition language (DDL) statement
.
In the Google Cloud console, go to the BigQuery page.
Go to BigQuery
In the query editor, enter the following statement:
ALTER
RESERVATION
` ADMIN_PROJECT_ID
.
region
-
LOCATION
.
RESERVATION_NAME
` SET
OPTIONS
(
slot_capacity
=
NUMBER_OF_BASELINE_SLOTS
,
autoscale_max_slots
=
NUMBER_OF_AUTOSCALING_SLOTS
);
Replace the following:
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.
Click play_circle
Run .
For more information about how to run queries, see Run an interactive query
.
bq
To update the size of a reservation, use the bq update
command with the --reservation
flag:
bq update \
--project_id= ADMIN_PROJECT_ID
\
--location= LOCATION
\
--slots= NUMBER_OF_BASELINE_SLOTS
\
--autoscale_max_slots= NUMBER_OF_AUTOSCALING_SLOTS
\
--reservation RESERVATION_NAME
Replace the following:
ADMIN_PROJECT_ID
: the project ID
LOCATION
: the location
of the 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.
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.
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.
bq update \
--project_id= ADMIN_PROJECT_ID
\
--location= LOCATION
\
--ignore_idle_slots=true \
--reservation RESERVATION_NAME
Replace the following:
ADMIN_PROJECT_ID
: the project ID
LOCATION
: the location
of 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:
SQL
Query the ignore_idle_slots
column of the INFORMATION_SCHEMA.RESERVATIONS_BY_PROJECT
view
.
In the Google Cloud console, go to the BigQuery page.
Go to BigQuery
In the query editor, enter the following statement:
SELECT
reservation_name
,
ignore_idle_slots
FROM
` ADMIN_PROJECT_ID
.
region
-
LOCATION
` .
INFORMATION_SCHEMA
.
RESERVATIONS_BY_PROJECT
;
Replace the following:
Click play_circle
Run .
For more information about how to run queries, see Run an interactive query
.
bq
Use the bq ls
command with the --reservation
flag:
bq ls --reservation \
--project_id= ADMIN_PROJECT_ID
\
--location= LOCATION
Replace the following:
The ignoreIdleSlots
field 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:
Each of the following predefined IAM roles includes this
permission:
BigQuery Admin
BigQuery Resource Admin
BigQuery Resource Editor
For more information about IAM roles in BigQuery,
see Predefined roles and permissions
.
Caution: You can delete a reservation with active commitments, but you are still charged for the remaining duration of the commitment. Deleting the reservation or switching associated projects to on-demand pricing doesn't stop these charges. For more information about commitment expiration, see commitment expiration
. For additional help with reservations, commitments, or costs, contact Google Cloud Support
.
Delete a reservation
Console
In the Google Cloud console, go to the BigQuery page.
Go to BigQuery
In the navigation menu, click Capacity management .
Click the Reservations tab.
Find the reservation you want to delete.
Expand the more_vert
Actions option.
Click Delete .
In the Delete reservation dialog, click Delete .
SQL
To delete a reservation, use the DROP RESERVATION
DDL statement
.
In the Google Cloud console, go to the BigQuery page.
Go to BigQuery
In the query editor, enter the following statement:
DROP
RESERVATION
` ADMIN_PROJECT_ID
.
region
-
LOCATION
.
RESERVATION_NAME
` ;
Replace the following:
ADMIN_PROJECT_ID
: the project ID of the administration project
that owns the reservation resource
LOCATION
: the location
of the reservation
RESERVATION_NAME
: the ID of the
reservation
Click play_circle
Run .
For more information about how to run queries, see Run an interactive query
.
bq
To delete a reservation, use the bq rm
command with the --reservation
flag:
bq rm \
--project_id= ADMIN_PROJECT_ID
\
--location= LOCATION
\
--reservation RESERVATION_NAME
Replace the following:
ADMIN_PROJECT_ID
: the project ID of the administration project
that owns the reservation resource
LOCATION
: the location
of 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.
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 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.
You might also be able to get
this permission
with custom roles
or
other predefined roles
.
Control access to a reservation
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:
Console
In the Google Cloud console, you can allow access to multiple reservation
resources by using a condition.
In the Google Cloud console, go to the IAM page.
Go
to IAM
Select a project, folder, or organization.
To grant the bigquery.resourceEditor
role to a principal who has a role
on the reservation resources:
On the View by principals tab, navigate to the appropriate
principal or use the Filter option to find the principal.
Click edit
Edit principal .
On the Assign roles page, click add
Add roles .
In the Search for roles field, enter bigquery.resourceEditor
.
Check the BigQuery Resource Editor option in the search results
and then click Apply.
Click Save .
Alternatively, to grant the bigquery.resourceEditor
role to a principal
who doesn't have a role on the reservation resources:
Click person_add
Grant Access .
On the Add principals page, in the New principals field, enter
the principal's identifier — for example, my-user@example.com
.
Click add
Add roles .
In the Search for roles field, enter bigquery.resourceEditor
.
Check the BigQuery Resource Editor option in the search results
and then click Apply.
In the BigQuery Resource Editor box, click Add condition .
On the Add condition page:
Enter values in the Title and Description fields.
In the Condition builder , add your condition. For example, to
add a condition that grants the role to all reservation names that
end with /reservation1
, for Condition type , choose Name ,
for Operator , choose Ends with , and for Value , enter /reservation1
.
Click Save .
Click Save .
bq
In the bq command-line tool, you can grant access to an individual reservation resource.
To grant access to a reservation, use the bq
set-iam-policy
command:
bq set-iam-policy --reservation RESOURCE
FILE_NAME
Replace the following:
For more information about IAM, see Manage access to other
resources
.
Prioritize idle slots with reservation groups
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.
Before you create a reservation group, you must
first enable reservation-based fairness
.
Required permissions
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
.
You might also be able to get
the required permissions through custom
roles
or other predefined
roles
.
Create a reservation group
To create a reservation group:
Console
In the Google Cloud console, go to the BigQuery page.
Go to BigQuery
In the navigation menu, click Capacity management .
Select the checkbox next to the reservation that you want to add to a group.
Click Create reservation group button in the table header.
In the Create reservation group pane, enter your group name in Group name field.
Optional: In the Reservations field, select additional reservations to be added to the group. Click OK .
Click Create .
The new reservation group is visible in the Slot reservations tab.
bq
To create a reservation, use the bq mk
command with the --reservation
flag:
bq mk \
--project_id= ADMIN_PROJECT_ID
\
--location= LOCATION
\
--reservation_group \ RESERVATION_GROUP_NAME
Replace the following:
ADMIN_PROJECT_ID
: the project ID
LOCATION
: the location
of the reservation.
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.
Use the google_bigquery_reservation_group
resource.
To authenticate to BigQuery, set up Application Default
Credentials. For more information, see Set up authentication for client libraries
.
The following example creates a reservation group named my-reservation-group
:
To apply your Terraform configuration in a Google Cloud project, complete the steps in the
following sections.
Prepare Cloud Shell
Launch Cloud Shell
.
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.
Note:
Terraform samples typically assume that the required APIs are
enabled in your Google Cloud project.
Add a reservation to a reservation group
To add a reservation to a reservation group, update the reservation_group
property of the reservation:
Console
In the Google Cloud console, go to the BigQuery page.
Go to BigQuery
In the navigation menu, click Capacity management .
Expand the more_vert
Actions option.
Click Edit .
In the Edit reservation group pane, select the reservations to be added in the Reservations field. Click OK .
Click Save .
The reservation group is updated with the latest member reservations.
bq
To update the reservation and set the reservation group, use the bq update
command with the --reservation
flag:
bq update \
--project_id= ADMIN_PROJECT_ID
\
--location= LOCATION
\
--reservation_group_name= RESERVATION_GROUP_NAME
\
--reservation RESERVATION_NAME
Replace the following:
ADMIN_PROJECT_ID
: the project ID
LOCATION
: the location
of the reservation
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.
List the reservations that have a reservation group
To list the reservation group information for your reservations, do the following:
Console
In the Google Cloud console, go to the BigQuery page.
Go to BigQuery
In the navigation menu, click Capacity management .
In the Slot reservations tab, you can see both reservation groups and reservations (without a parent group) in the table.
Click the expansion button next to a reservation group, the reservation group row is expanded to show the member reservations in the following rows.
bq
To list the reservations and include the reservation group information, use the bq ls
command with the --reservation
flag:
bq ls \
--project_id= ADMIN_PROJECT_ID
\
--location= LOCATION
\
--reservation
Replace the following:
ADMIN_PROJECT_ID
: the project ID
LOCATION
: the location
of the reservation
Remove a reservation from a reservation group
To remove a reservation from a reservation group, update the reservation_group
property of the reservation to be the empty string:
Console
In the Google Cloud console, go to the BigQuery page.
Go to BigQuery
In the navigation menu, click Capacity management .
Expand the more_vert
Actions option.
Click Edit .
In the Edit reservation group pane, select the reservations to be removed in the Reservations field. Click OK .
Click Save .
The reservation group is updated with the latest member reservations.
If the reservation to be removed is the last one in the group:
In the Google Cloud console, go to the BigQuery page.
Go to BigQuery
In the navigation menu, click Capacity management .
Expand the more_vert
Actions option.
Click Edit .
Click Ungroup in the Edit reservation group pane.
The reservation group is deleted.
bq
To remove the reservation from the reservation group, use the bq update
command with the --reservation
flag:
bq update \
--project_id= ADMIN_PROJECT_ID
\
--location= LOCATION
\
--reservation_group_name="" \
--reservation RESERVATION_NAME
Replace the following:
ADMIN_PROJECT_ID
: the project ID
LOCATION
: the location
of the 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.
Remove an empty reservation group
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.
Console
In the Google Cloud console, go to the BigQuery page.
Go to BigQuery
In the navigation menu, click Capacity management .
Find the reservation group you want to delete. Ensure it has no reservations listed under it.
Expand the more_vert
Actions option for the reservation group.
Click Edit .
Click Ungroup in the Edit reservation group pane.
bq
To delete an empty reservation group, use the bq rm
command with the --reservation_group
flag:
bq rm \
--project_id= ADMIN_PROJECT_ID
\
--location= LOCATION
\
--reservation_group RESERVATION_GROUP_NAME
Replace the following:
ADMIN_PROJECT_ID
: the project ID
LOCATION
: the location
of the reservation
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.
To learn more about reservation groups, see Reservation groups
.
Troubleshoot
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.
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-05-20 UTC.
Need to tell us more?
[[["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-05-20 UTC."],[],[]]