Skip to content

A userscript that dynamically replaces BigQuery’s query size estimate (GB) with an estimated cost based on Google’s on-demand pricing. Works in Chrome, Firefox, Edge, and more with ViolentMonkey or TamperMonkey.

License

Notifications You must be signed in to change notification settings

dannberg/bigquery-cost-estimator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

BigQuery Cost Estimator

📊 Automatically replaces BigQuery’s query size estimate (GB) with the estimated cost in USD.

GitHub GreasyFork BigQuery

Screenshot of before and after this script is enabled

🚀 Overview

Google BigQuery displays a message like:

"This query will process 11.37 GB when run."

This script dynamically replaces that text with the estimated cost based on Google’s on-demand pricing. 💰 Cost Calculation: $6.25 per TB processed


Features

  • Real-time cost calculation as you type queries
  • MutationObserver support for dynamic updates
  • Lightweight & fast, no external dependencies
  • Works in Chrome, Firefox, Edge, Brave, & Safari

🛠 Installation

1️⃣ Install a Userscript Manager

This script works with:

2️⃣ Install the Script

🔹 From GreasyFork: BigQuery Cost Estimator

🔹 From GitHub: Click Here to install manually.

3️⃣ Open BigQuery & Run a Query

  • The GB estimate will be replaced with the cost estimate automatically.

🏗 How It Works

  1. Finds the GB estimate in BigQuery’s UI.
  2. Extracts the numeric value from the message.
  3. Calculates the cost using $6.25 per TB.
  4. Replaces the text dynamically.

📌 Example Calculation:

Query processes: 11.37 GB
Cost = (11.37 GB ÷ 1024) × 6.25
Cost = $0.07

BigQuery now displays:

"Estimated cost: $0.07"


Technical Details

  • Uses MutationObserver to detect changes in BigQuery’s UI.
  • Targets the element: div.cfc-truncated-text.ng-star-inserted.
  • Does not interfere with BigQuery’s functionality.

🚀 Contributing

Want to improve this script? PRs are welcome!

To Contribute:

  1. Fork this repo
  2. Clone your fork
   git clone https://github.com/dannberg/bigquery-cost-estimator.git
  1. Make changes & push
git commit -m "Improved cost calculation"
git push origin main
  1. Submit a Pull Request (PR)

📝 License

This project is licensed under the MIT License – you’re free to use, modify, and distribute it!


🔗 Links & Resources

About

A userscript that dynamically replaces BigQuery’s query size estimate (GB) with an estimated cost based on Google’s on-demand pricing. Works in Chrome, Firefox, Edge, and more with ViolentMonkey or TamperMonkey.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published