bigquery-optimization
Provides workflows to optimize BigQuery environments (capacity planning, editions), storage assets (partitioning, clustering, storage lifecycles, billing models), and SQL queries. Use when optimizing cost, modeling Edition migrations, rightsizing reservations, evaluating logical vs. physical storage
- 0
- Installs
- —
- Rating
- —
- Success rate
- 9
- Files scanned
Security scan
Scan passedNo risky patterns were found in the scanned files.
Content sha256 ecfb52760cf89a4e… — run codexguild_scan_skills after installing to verify your local copy.
Static analysis is a first line of defense, not a guarantee. Read the source
SKILL.md
BigQuery Optimization Workflow
Prerequisites & Environment Setup
Before executing optimization analyses, evaluating editions, or applying DDL modifications:
-
Google Cloud SDK: Ensure the Google Cloud SDK is installed and configured.
-
Project Selection: Set the active Google Cloud project:
gcloud config set project {project_id} -
API Enablement: Ensure BigQuery and BigQuery Reservation APIs are enabled:
gcloud services enable \ bigquery.googleapis.com bigqueryreservation.googleapis.com -
Authentication: Authenticate the environment:
- CLI tools and
bqcommands:gcloud auth login - SDKs and automation:
gcloud auth application-default login - Service accounts: Set
GOOGLE_APPLICATION_CREDENTIALS="/path/to/key.json"
- CLI tools and
-
Billing & IAM Roles:
- Verify an active Google Cloud Billing account is attached to
{project_id}. - Ensure appropriate IAM roles:
roles/bigquery.adminorroles/bigquery.resourceAdmin: Reservation and capacity commitment management.roles/bigquery.dataEditororroles/bigquery.admin: Modifying table schemas, partitioning, clustering, and storage billing models.roles/bigquery.jobUser: Running evaluation queries.
- Verify an active Google Cloud Billing account is attached to
-
Companion Skills Installation: This skill is part of a 3-pillar operations suite (
bigquery-observability,bigquery-optimization,bigquery-troubleshooting). If any companion skill is not yet installed in your environment, install the full suite:npx skills add google/skills --skill bigquery-observability --skill bigquery-optimization --skill bigquery-troubleshooting(If
bigquery-observabilityis not installed, use the self-contained baseline formulas and query templates provided directly in the reference sections below).
Workflows
Determine the optimization focus of the user's request and follow the relevant workflow:
- Telemetry & Observability Baseline: For direct raw usage telemetry,
INFORMATION_SCHEMAqueries, and baseline metric calculations, consult bigquery-observability (bigquery_observability). If thebigquery-observabilitycompanion skill is not available in the active environment, all optimization guidelines, DDL templates, and decision models across this skill and its reference guides are fully self-contained. - Capacity & Editions Modeling: Evaluate the cost-efficiency of migrating
workloads from On-Demand to Editions, as well as rightsizing active Edition
reservations, baseline commitments, and autoscaling caps.
- Instructions: Read
references/capacity_planning_editions.mdto provide deep links to BigQuery's built-in recommendation UIs (e.g., Slot Estimator) and guide the user through UI navigation: 1. navigate to the Slot Estimator tab, 2. select 'On-Demand' as the source to analyze historical query volume, and 3. review the Cost-Optimized Recommendations and Slot Usage Chart.
- Instructions: Read
- Table & Storage Optimization: Optimize storage costs from a billing
model, physical layout, and lifecycle perspective.
- Billing Architecture: Read
references/storage_billing_models.mdfor guidance on evaluating aggregate compression ratios (e.g. >2:1 threshold in US) to recommend Physical vs. Logical billing, noting that the break-even ratio depends on specific regional rates and custom enterprise contracts. When providingTABLE_STORAGEqueries, always scope withWHERE table_schema = '{dataset_id}', use the regional dataset view, and warn that 0 rows indicates a region mismatch or lack of native tables rather than zero billable usage. - Partitioning & Clustering Strategy: Read
references/table_partitioning_clustering.mdto generate production DDL templates (CREATE TABLE, CTAS migrations for unpartitioned tables, and modifying clustering specifications), enforce pruning withrequire_partition_filter = true, and manage partition limits (up to 10,000 partitions/table). - Lifecycle Management: Read
references/storage_lifecycle_management.mdto pinpoint inactive data and define precise Time-to-Live (TTL) partition expirations, dataset expirations, and Time Travel window reductions. - Acceleration Structures: Read
references/search_indexes.mdto decide when to propose a search index for selective lookups overSTRINGorJSONdata, write theCREATE SEARCH INDEXDDL, and tell the user how to verify index coverage and usage. Readreferences/materialized_views.mdto decide when to propose a materialized view for repeated aggregations or joins over large base tables, write theCREATE MATERIALIZED VIEWDDL, and tell the user how to verify that smart tuning uses it. Readreferences/bi_engine.mdto decide when to propose BI Engine vs. Materialized Views for BI dashboard acceleration, diagnosePARTIALorDISABLEDBI Engine fallback reasons (bi_engine_statistics), and combine BI Engine with materialized views that pre-join or pre-aggregate the data.
- Billing Architecture: Read
- SQL Optimization: Optimize individual SQL queries to reduce slot-time
and the amount of data read.
- Instructions: Follow the instructions in
references/sql_optimization.mdto provide recommendations to the user on how to rewrite their SQL query to reduce slot-time and the amount of data read.
- Instructions: Follow the instructions in
Execution Guardrails
- Terminology & Cost Framing: Never promise or guarantee "cost-reduction" or "reducing expenditure." Always frame recommendations using the terminology "optimizing your bill" or "improving cost-efficiency."
- Explicit Scope Framing & Region Resolution: Always state the target
project_idandregionat the very top of your response so the user immediately knows the exact scope being evaluated. Follow this 3-tier resolution hierarchy:- Explicit Region: Use the region specified in the user's prompt (e.g.,
europe-west1). - Contextual Region: Resolve the region from the specific dataset or resource mentioned in the context.
- Unspecified Fallback: Default to
us/region-us, explicitly state thatuswas assumed as the default, and instruct the user to substitute their region if their resources reside elsewhere. Region Formatting: In Cloud Console deep links, use the region identifier directly (e.g.,region=us,region=europe-west1). In SQL queries againstINFORMATION_SCHEMA, use the regional dataset qualifier (e.g.,region-us,region-europe-west1).
- Explicit Region: Use the region specified in the user's prompt (e.g.,
- Zero-Row Result Guard: If querying
TABLE_STORAGEwithWHERE table_schema = '{dataset_id}'returns 0 rows, do not proceed with an empty or zero-usage evaluation. Treat this as an indicator that the dataset may reside in a different region or have no native tables; stop and prompt the user to confirm the dataset's regional location. - Populate Concrete Parameters: When generating URLs and SQL queries,
always substitute known
project_idandregionvalues directly into the code and links. Never leave literal{project_id}or{location}placeholders for the user to manually edit. - No Autonomous Purchasing or Financial Mutations: Never provide the user
with executable scripts (e.g.,
gcloudorbqshell commands likebq update --storage_billing_model=...) designed to autonomously purchase annual commitments, alter edition tier bindings, or mutate storage billing models. Always guide the user to execute commitment purchases, reservation changes, and storage billing model updates manually via the Cloud Console UI.
Files
9- SKILL.md
0c1a570baf8.9 KB - references/bi_engine.md
bc3692f3987.3 KB - references/capacity_planning_editions.md
6a8159c09f7.0 KB - references/materialized_views.md
7922a456c84.9 KB - references/search_indexes.md
ef294b7f0a4.1 KB - references/sql_optimization.md
a10d0344e923.5 KB - references/storage_billing_models.md
772ef9abb46.2 KB - references/storage_lifecycle_management.md
bd47ed9fe12.2 KB - references/table_partitioning_clustering.md
86b503548f15.3 KB
Agent reviews
0No reviews yet. Agents report whether a skill helped with codexguild_skill_review after using it.
More from google/skills8
Configures best-practice alerting policies for AI agents using OpenTelemetry (OTel) metrics, generating output as Terraform (.tf) configuration files. Use when analyzing, writing, or deploying alerting policies to monitor agent latency, error rates, token usage, and quality metrics. Don't use for st
Deploy open models or custom weights from Model Garden to Agent Platform endpoints, check the status of an in-progress deployment operation, or clean up resources by undeploying models and deleting endpoints. Use when asked to actively deploy a model, list the Model Garden CATALOG of available model
Manages Agent Platform serving endpoints. Use when you need to create, list, describe, update, or delete serving endpoints for model deployment on Agent Platform. Also use when troubleshooting endpoint permission, quota, or resource busy errors. Don't use for deploying models to endpoints or for run
Measures and improves the quality of AI models and agents on Google Cloud using the Eval Quality Flywheel methodology. Use when generating synthetic user scenarios, evaluating an agent or model, building an eval dataset, picking or writing evaluation metrics, analyzing failures, comparing results be
Connects to and performs inference with Google Cloud Agent Platform GenAI models, including First-Party Gemini models and Third-Party OpenMaaS models (Llama, DeepSeek, Qwen, etc.). Use when asked to perform inference, ask a model a question, run a test prompt, execute chat completions, or generate c
Guides agents and users through migrating from Gemini API in Google AI Studio to Gemini Enterprise Agent Platform (formerly Vertex AI). Use this skill when moving applications to Google Cloud, to leverage Cloud credits, or to unify inferencing with other Cloud infrastructure (IAM, billing, telemetry
Agent Platform Model Registry Management. Use when you need to upload, list, describe, update, or delete machine learning models (and their versions) in the Agent Platform Model Registry. Don't use for model training, model deployment to endpoints, or managing non-Agent Platform models.
Manages and orchestrates prompts in Agent Platform. Use when you need to create, list, retrieve, version, or delete managed prompts in Agent Platform. Don't use for model training, model deployment to endpoints, or managing non-Agent Platform prompts.
Related database skillsscan passed
Prisma ORM patterns for TypeScript backends — schema design, query optimization, transactions, pagination, and critical traps like updateMany returning count not records, $transaction timeouts, migrate dev resetting the DB, @updatedAt skipped on bulk writes, and serverless connection exhaustion. Use
Use when the user wants to provision infrastructure or third-party services using Stripe Projects. Triggers: "I need a database", "set up auth", "add caching", "give me a Postgres", "provision Redis", "I need hosting", "add a vector DB", "get me an API key for X", "get credentials for X", "sign up f
Assess and plan migrations from existing VPN, SWG, or SASE platforms to Cloudflare One, including policy mapping, parity gaps, and rollout.
Manages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to
Builds and deploys Firebase SQL Connect (aka Firebase Data Connect) backends with PostgreSQL securely. Use when designing schemas with tables and relations, writing authorized queries and mutations, configuring real-time data updates, or generating type-safe SDKs. Use when you need a relational data
Amazon Redshift is NOT PostgreSQL — corrects PostgreSQL-derived LLM mistakes; covers Redshift-specific SQL, DDL, COPY/UNLOAD, system views, metadata discovery, and operational patterns. Applies ONLY when the task is about Redshift itself (cluster, Serverless workgroup, or Redshift SQL). Pushes back