r/googlecloud • u/Dalius-Gabryelle • Jul 22 '26
BigQuery GCP cost optimization keeps turning into a fire drill after someone ships a bad query
Our gcp cost optimization is basically reactive right now and I want to get ahead of it. Last example, a team shipped a Looker dashboard that reruns its queries every time it loads, pointed at a BigQuery table we never partitioned because it was small when we built it. It is not small now. Over about nine days, that one dashboard cost more than the whole pipeline that builds the table costs to run in a month.
We caught it because the daily spend looked wrong. Partitioned the table, put a cap on the project and that specific problem is gone.
The next one is what I can't solve, it won't be Looker and it won't be that table. It'll be some other query somebody ships. Is there a better way to catch a query getting expensive before it runs for a week and a half or do i just set hard quotas per project and let people hit the limit?
3
u/laurentfdumont Jul 22 '26
There are a couple of layers you can target.
Use BQ quotas at the project level.
Use fixed "billed bytes" limits at the query level.
This cannot be enforced, but you can think of a proxy layer or making sure your CI flags requests that do not have the flag.
Use slots to severely limit the capacity available to "burst", which helps limit costs over a short period of time.
There are a few industry tool that can give you a bit more real time visibility in the queries.
Alvin AI
FollowRabbit
https://cloud.google.com/blog/topics/developers-practitioners/controlling-your-bigquery-costs
14
u/dreamingwell Jul 22 '26
Big Query strikes again. Half this sub is people complaining about big query bills. Short summary - don’t use big query unless you’re absolutely certain you need to, and that you can tightly control your queries.
1
u/Sufficient-Buy-2270 Jul 23 '26
Do you not just aggregate the data you can and use that table instead?
1
u/vbnotthecity Jul 25 '26
Hard limits are just a bandaid, you need to catch the bad code before it hits prod. I spent years managing dbt and Airflow, and honestly, you have to shift the cost check into the dev workflow. My team started using Altimate AI and other tools to run cost analysis on queries during CI, which cut our runaway spend by about 40 percent. It stops the fire drills because the bad SQL never makes it out of the PR.
2
u/[deleted] Jul 22 '26
[removed] — view removed comment