ETLMCPData Conveyance Works
Log in Start free
Guides

Controlling BigQuery cost for dashboards and agents

Why LIMIT doesn't cut a BigQuery bill, and how dry runs, maximum bytes billed and daily quotas stop a dashboard or agent from running up costs.

Coming This destination is coming.

On BigQuery's on-demand pricing you pay for the bytes a query reads, not for the rows it returns, and each project gets 1 TB of query processing free a month. Adding LIMIT 10 to a query on an ordinary table does not make it cheaper: BigQuery still reads, and bills, the data it scans. What stops a dashboard or an agent from running up a bill is checking the bytes before a query runs (a dry run), capping them per query (maximum bytes billed) and capping them per day (custom quotas). etlmcp's BigQuery destination is coming; the sections below on its table describe what the code does today.

What you pay for on demand

Google's cost guide sets these rules:

  • Bytes read, not rows returned. On-demand queries are billed per TiB processed, always counted on logical (uncompressed) bytes, whatever storage billing model the dataset uses.
  • A floor per table and per query. Each table a query references is billed at least 10 MiB, and each query at least 10 MiB as well.
  • The free tier is per project. Each project gets 1 TB of query processing a month at no charge. When a project without a paid Cloud Billing account goes past it, queries fail with an error about the free query bytes quota until you upgrade.
  • Looking is free. Previewing a table in the console, bq head and the tabledata.list method cost nothing and do not count against quotas. Google advises against running queries just to explore data.

Why LIMIT does not save money

LIMIT trims the result, not the scan. On a table that is not clustered, BigQuery reads the whole table and then returns the first rows, so you are billed for the full scan. Google's cost guide says not to use LIMIT to control cost on non-clustered tables.

On a clustered table it can help: BigQuery stops reading blocks once it has enough rows, and you pay only for what it read. It depends on data layout, so it is not a control.

When an agent wants a sample of the data, SELECT * with LIMIT 5 on a large table is still a full scan. Use the console's preview or bq head instead.

Check the bytes first with a dry run

A dry run validates a query and reports how many bytes it would process, without running it. You can request one with bq query --dry_run, with dryRun set to true in the API, or through the client libraries. In the console, the query validator shows the same estimate before you press Run.

The estimate is an upper bound: the bytes actually billed can be lower. Two exceptions to know: a dry run reports 0 bytes on tables protected by row-level security, and on capacity (slot) pricing a dry run cannot tell you the cost in advance; you read total_slot_ms afterwards instead.

Run a dry run on every query you save into a dashboard or hand to an agent as a template. It is also how Google suggests confirming that a filter on the partition column actually prunes partitions.

Cap a single query with maximum bytes billed

Maximum bytes billed is a per-query ceiling. BigQuery estimates the bytes before it starts; if the estimate is over your cap, the query fails and you are not charged. You set it in the console under Query settings and Advanced options, with bq query --maximum_bytes_billed, or with the maximumBytesBilled property of a query job in the API.

On clustered tables the estimate is an upper bound, so a query can fail even though the bytes it would really have billed fit under the cap. Set the cap with that headroom in mind.

For a service account that a dashboard or an agent uses, set the cap in the tool's connection or job settings where the tool allows it.

Cap a whole day with custom quotas

A custom quota limits the bytes processed per day, for a whole project or for each user in it. When the quota is used up, users cannot run more queries until it resets: it is a hard stop, not a warning. Setting one needs the right Google Cloud roles; the current quota values are on BigQuery's quotas and limits page.

Quotas apply to everything in the project, including etlmcp. When the destination is available, each run delivers its rows by running a transaction in your project that deletes the pipeline's rows it is replacing (those in the run's date range) and inserts the new ones. If BigQuery reports that the project has used up a quota, etlmcp fails the run with project {…} has used up a BigQuery quota; raise it in Google Cloud or run again when it resets. If you set a tight project quota for dashboards, set it per user, or run dashboards from a separate project, so that loads are not the job that gets stopped.

A related message comes from the BigQuery sandbox, which has no billing account: etlmcp's delete-and-insert needs DML, so a sandbox project fails with BigQuery sandbox projects cannot replace rows; enable billing on the project.

How etlmcp's table keeps scans small

When etlmcp creates the table, it partitions it by day on the date column (a DATE) and clusters it on _etlmcp_pipeline_id, the column that says which pipeline wrote each row. Metrics such as cost, impressions and clicks are FLOAT64; names and ids are STRING. Two habits keep queries on that table cheap:

  • Filter on date with constant values. BigQuery skips partitions outside the range only when the filter compares the bare column (or one of the functions BigQuery lists as safe) with constants. A function like FORMAT_DATE on the column, arithmetic on it, or a comparison with a subquery reads every partition.
  • Filter on _etlmcp_pipeline_id when several pipelines share a table. The table is clustered on that column, so BigQuery can skip blocks that belong to other pipelines.

Google's performance guide also says to query only the columns you need, since extra columns mean extra reading. This query reads two metrics for thirty days of one pipeline:

SELECT
  `date`,
  SUM(cost)   AS cost,
  SUM(clicks) AS clicks
FROM `my_project.ads.performance`
WHERE `date` >= DATE '2026-10-01'
  AND `date` <  DATE '2026-10-31'
  AND `_etlmcp_pipeline_id` = 'your-pipeline-id'
GROUP BY `date`
ORDER BY `date`;

If a dashboard reruns the same multi-step query many times a day, write its result to a table of its own and point the charts at that table. Google notes that storing a result costs far less than reprocessing the source data, and a default table expiration on the dataset deletes old results for you.

Agents and etlmcp's own query tool

An agent that writes SQL against BigQuery through a database tool is billed like any other user, so give its service account a maximum bytes billed setting and a per-user quota. etlmcp's own query_data tool is different: it reads the daily rows etlmcp stores for your workspace, not your BigQuery table, so it starts no BigQuery job and adds nothing to your bill. It returns at most 500 rows per call and marks the result truncated when more matched, so the agent narrows the dates instead.

For tool-specific settings, see the guides for Data Studio (formerly Looker Studio), Power BI, Metabase and Tableau on BigQuery.

Related

Sources

  1. Estimate and control costs — docs.cloud.google.com, checked
  2. Optimize query computation — docs.cloud.google.com, checked
  3. Query partitioned tables — docs.cloud.google.com, checked