How does Big Query assign slots to the queries?

Google Cloud BigQuery uses a dynamic slot allocation strategy for running queries. This means that the number of slots assigned to a query can change over time based on the workload and the availability of resources. The actual number of slots used by a query can be less than the maximum number of slots available in your reservation.

In your second use case, even though a baseline of 600 slots was available, the query only utilized 40 slots to process 18GB of data. This is because BigQuery only assigns the number of slots that are necessary for the query’s execution.

The reason the second use case required fewer slots could be due to the fact that some of the data had already been processed by a previous query within the same reservation. BigQuery checks for any pre-processed data that can be reused at the start of a query. If such data is available, the query can be executed with fewer slots.

In this instance, a prior query had already processed 9GB out of the total 18GB of data. Consequently, the second query only needed to process the remaining 9GB, which it managed to do using 40 slots.

Here’s a summary table of the factors influencing how BigQuery assigns slots to queries:

Factor Explanation
Available Slot Count The total count of slots available in the reservation assigned to the query.
Query Priority The priority level of the query, which determines its scheduling order. High-priority queries are scheduled before low-priority ones.
Query Size and Complexity The size and complexity of the query influence the number of slots it requires. Larger and more complex queries need more slots.
Pre-Processed Data If there’s any pre-processed data that can be reused, the query will require fewer slots for data processing.