BigQuery is affordable and fast, but it can quickly consume a lot of processing power, increasing the bills if not used properly. In BigQuery, slots decide the amount of processing power that directly impacts cost. First, let’s understand slots.
In BigQuery, slots are the computational capacity required to execute a SQL query. Slots play a crucial role in pricing and resource allocation. BigQuery manages the slot allocation, and the number of slots allocated to a job depends on
In supplement to consumption-based pricing, BigQuery also provides flat-rate pricing, that is, you can buy a fixed number of slots over some period which provides more granularity in planning capital.
BigQuery is fast because it uses heavy parallel processing by converting the declarative SQL into stages.
Without further delay, let’s see the best practices in BigQuery for:
BigQuery is a columnar database. In other words, all columns from a table are stored separately at the physical level. Hence, we should always avoid using select *
in our queries. This practice will limit the data processed.
For looking at the sample data, we should use the preview option instead of the query. The preview feature in BigQuery is free.
We should use a pricing calculator to check the costs before pushing the query to production. On-demand queries are charged based on the number of bytes read, and we can calculate the price based on bytes read.
We should use dashboard for viewing costs and logs. The dashboard can provide us with good insights on our usage of BigQuery.
Partitioning in BigQuery allows us to scan only the required data and reduce costs.
FROM bigquery-public-data.noaa_gsod.good*
.