2022-08-13

BigQuery Query Plan

BigQuery Query Plan

In BigQuery, a query plan is provided for executed queries. Deciphering query plans can lead to further query optimization.

Let's execute the following SQL in BigQuery:

SELECT
    subject AS subject,
    COUNT(*) AS num_duplicates
FROM
    `bigquery-public-data.github_repos.commits`
GROUP BY
    subject
ORDER BY
    num_duplicates DESC
LIMIT 10
;

BigQuery Query Plan | 1

By clicking the "EXECUTION DETAILS" button, you can review the query plan.

BigQuery Query Plan | 2

BQ Visualizer

Using the BQ Visualizer, you can visualize SQL execution results, including BigQuery query plans and Slot usage.

Visit https://bqvisualiser.appspot.com/ and click the "Login" button to perform authentication.

BigQuery Query Plan | 3
BigQuery Query Plan | 4

After authentication, enter the project and job ID, then click the "GET" button.

BigQuery Query Plan | 5

You can now review the visualized query plan.

BigQuery Query Plan | 6

References

https://cloud.google.com/bigquery/docs/query-plan-explanation
https://bqvisualiser.appspot.com/

Ryusei Kakujo

researchgatelinkedingithub

Focusing on data science for mobility

Bench Press 100kg!