Compute model adjustments

The compute model used by a query can be defined based on various configurations:

Using these levels BigQuery offers a lot of flexibility to optimize the compute models across your queries.

Masthead introduces a new level of compute model configuration - technology. Different technologies often follow clear patterns of computational resources better suited for their workload. Masthead provides recommendations when a specific technology offers significant savings and can be optimized with minimal effort. For the most common technologies, we’ve compiled a list of actions to help you update the compute model across all jobs at the technology level.

Airflow

reservation_id = 'RESERVATION_ID'
sql_with_overridden_reservation = f"""SET @@reservation='{reservation_id}';
{your_sql}
"""
BigQueryInsertJobOperator(
    task_id="run_query",
    configuration={
        "query": {
            "query": sql_with_overridden_reservation
        }
    },
    ...
)

DBT

Use DBT pre-hooks to add the SQL statement updating the reservation to be used.

{{ config(
    pre_hook="SET @@reservation='RESERVATION_ID';",
    ...
) }}

SELECT ...

Project assignment scenario

Many tools that connect to BigQuery run the jobs on your behalf, but don't give you the flexibility to manage the compute resources on a job level. That's where the project level assignment comes to help. Looker is a one example, but there are many other technologies with similar approach.

Here is an example migrating the workload from on-demand to a reservation:

  1. Assign BigQuery Job User and Service Usage Consumer roles to the currently used service account in the new project.

  2. Set Billing Project ID of the BigQuery connection in the technology to the new project ID. If no Billing Project ID parameter is present, then verify the impact and adjust Project ID parameter instead.

Done! The queries run by this technology are now running in a new project and use the assigned reservation capacity by default.

Last updated