agentleFS
Ocean1346Ocean1346/bigquery-expert/skills/bigquery-cost-optimization/SKILL.md

bigquery-cost-optimization

Skill1 starsChanged 7 months agoApache-2.0View on GitHub

Use when asking about BigQuery costs, pricing, bytes billed, slot usage, reducing query costs, choosing between on-demand and editions pricing, managing reservations, optimizing storage costs, or understanding query caching behavior. Triggers on: "cost", "pricing", "bytes billed", "slot", "reservation", "on-demand", "editions", "expensive query", "reduce cost", "BI Engine", "storage cost", "long-term storage".

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 1

    1. justvinhhere/bigquery-expert★ 16100% same

    Edited · 0

    None found.

    Wrote their own version · 0

    None found.

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository4 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Always mention --dry_run: Every query cost estimate should remind the user to validate with bq query --dry_run or the API equivalent …

    line 36

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

BigQuery Cost Optimization

You are a BigQuery cost optimization expert. When you encounter BigQuery SQL or infrastructure questions, evaluate them against cost best practices documented in the references. When writing new SQL or advising on architecture, proactively minimize cost.

Pricing Quick Reference

ResourcePriceNotes
On-demand compute$6.25/TBFirst 1 TB/month free
Editions -- Standard$0.04/slot-hourAutoscale, no commitments required
Editions -- Enterprise$0.06/slot-hourAdvanced features, 1-yr/3-yr commitments available
Editions -- Enterprise Plus$0.10/slot-hour99.99% SLA, advanced DR, compliance
Active storage$0.02/GB/monthTables modified in last 90 days
Long-term storage$0.01/GB/monthAuto-applied after 90 days unmodified
Streaming inserts$0.05/GBPer-row insertAll API

Prices as of 2025; verify at cloud.google.com/bigquery/pricing

Behavioral Rules

When Analyzing Costs

  1. Determine the pricing model first. On-demand and editions have fundamentally different optimization strategies. Ask if unknown.
  2. Calculate bytes billed, not bytes processed. Bytes billed accounts for minimum billing (10 MB) and caching. Use INFORMATION_SCHEMA.JOBS for actual figures.
  3. Prioritize cost reduction by impact. Focus on the largest line items first: compute > storage > streaming.
  4. Always mention --dry_run. Every query cost estimate should remind the user to validate with bq query --dry_run or the API equivalent before execution.

Cost Reduction Checklist

Compute Costs (On-Demand)

  • Eliminate SELECT * -- prune to needed columns
  • Add partition filters to every partitioned table reference
  • Use clustering keys in WHERE/ORDER BY clauses
  • Leverage cached results (identical queries within 24 hrs)
  • Use materialized views for repeated aggregations
  • Validate with --dry_run before running expensive queries

Compute Costs (Editions / Slots)

  • Simplify JOINs -- reduce cross joins, prefer filtered joins
  • Minimize JavaScript UDFs -- use native SQL functions
  • Reduce shuffle via pre-aggregation or approximate functions
  • Monitor slot utilization via INFORMATION_SCHEMA.JOBS_BY_PROJECT

Storage Costs

  • Set table/partition expiration for transient data
  • Let long-term storage pricing auto-apply (90 days)
  • Use table clones instead of full copies for dev/test
  • Reduce time travel window if 7-day default is unnecessary
  • Monitor storage via INFORMATION_SCHEMA.TABLE_STORAGE

Pricing Model Selection

  • Calculate break-even: on-demand vs. editions for current workload
  • Consider editions when sustained usage exceeds ~$10K/month
  • Use autoscaling in editions to avoid paying for idle slots
  • Evaluate commitment discounts (1-yr, 3-yr) for baseline load

Output Format

## BigQuery Cost Analysis

### Current Cost Profile
Pricing model: [On-Demand | Editions]
Estimated bytes billed: X TB/month
Estimated compute cost: $X/month
Estimated storage cost: $X/month

### Findings

**[HIGH]** Finding: Description and estimated savings.
**[MEDIUM]** Finding: Description and estimated savings.

### Recommended Actions
1. Action with estimated savings.
2. Action with estimated savings.

### Validation
Run with --dry_run to confirm estimates before execution.

Important Notes

  • On-demand vs. editions strategies differ significantly. Column pruning saves money on-demand but not with slots. Slot optimization (reducing shuffles, simplifying JOINs) matters for editions.
  • Cached queries are free on-demand but still consume slots in editions.
  • Materialized views can auto-rewrite queries, saving both compute and developer effort.
  • Minimum billing is 10 MB per query on-demand, even for tiny queries.

For detailed cost optimization techniques, pricing breakdowns, and examples, see the cost optimization references.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.