Querying Data

This document provides an overview of querying data in BigQuery.

Types of queries

After you load your data into BigQuery, you can query or view the data in your tables. BigQuery supports two types of queries:

By default, BigQuery runs interactive queries, which means that the query is executed as soon as possible.

BigQuery also offers batch queries. BigQuery queues each batch query on your behalf and starts the query as soon as idle resources are available, usually within a few minutes.

Running queries

You can run interactive and batch queries using:

Saving and sharing queries

BigQuery allows you to save queries and to share queries with others.

When you save a query, it can be private (visible only to you), shared at the project level (visible to project members), or public (anyone can view it). For more information, see saving and sharing queries.

Query jobs

Jobs are actions that you construct and that BigQuery executes on your behalf to load data, export data, query data, or copy data.

Because jobs can potentially take a long time to complete, they execute asynchronously and can be polled for their status. Shorter actions, such as listing resources or getting metadata are not managed by a job resource.

When you perform actions in the web UI or CLI, a job resource is automatically created and run. When you use the API, you start a job by calling the jobs.insert method using a unique job ID that is generated by your client code.

Query pricing

Query pricing refers to the cost of running your SQL commands and user-defined functions. BigQuery charges for queries by using one metric: the number of bytes processed. You are charged for the number of bytes processed whether the data is stored in BigQuery or in an external data source such as Google Cloud Storage, Google Drive, or Google Cloud Bigtable.

The first 1 TB of data processed per month is free of charge (per billing account). Beyond your first 1 TB of data processed in a month, you are charged according to the on-demand pricing model.

BigQuery also offers flat-rate pricing and pricing for high-compute queries. For more information, see query pricing.

Quotas and query cost controls

BigQuery enforces project-level quotas on running queries. For information on query quotas, see quota policy.

To control query costs, BigQuery provides several options including custom quotas and billing alerts. For more information, see cost controls.

You can also use audit logs to analyze query behavior and Stackdriver monitoring to view query metrics.

Monitor your resources on the go

Get the Google Cloud Console app to help you manage your projects.

Send feedback about...