BigQuery Troubleshooting

BigQuery Troubleshooting

Walks through root-cause diagnosis of failing, slow or unexpectedly expensive BigQuery jobs, query plan bottlenecks and cost spikes, with remediation steps.

Skill files8 files

references/

SKILL.md223 lines
1
---
2
name: bigquery-troubleshooting
3
metadata:
4
version: "1.1.2"
5
category: BigDataAndAnalytics
6
publisher: google
7
description: >-
8
Provides diagnostic workflows and step-by-step root-cause analysis
9
procedures for actively broken, failing, or slow BigQuery jobs, execution
10
graph and query plan stage bottlenecks, system performance issues, or
11
unexpectedly expensive workloads. Use when interpreting symptoms, isolating
12
bottlenecks, diagnosing cost spikes (on-demand query spend, capacity slot
13
autoscaling, storage growth), execution graph stages or substep variables,
14
identifying root causes, and determining remediation steps. Don't use for
15
writing or optimizing SQL, proactive capacity planning, or storage layout
16
design (use bigquery-optimization), or when the user already knows which
17
telemetry they want and just needs the query (use bigquery-observability).
18
---
19
20
# BigQuery Troubleshooting
21
22
## Attribution
23
24
**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you
25
MUST read [Usage Attribution](references/attribution.md). For commands executed
26
directly in the terminal (never in generated scripts, Terraform, or user code),
27
prefix `gcloud` with
28
`CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:bigquery-troubleshooting)"`
29
and append `agent-skills/1.0 (skill:bigquery-troubleshooting)` to `User-Agent` headers.
30
31
## Prerequisites & Environment Setup
32
33
Before running diagnostic queries or investigating incident telemetry:
34
35
1. **Google Cloud SDK**: Ensure the
36
[Google Cloud SDK](https://cloud.google.com/sdk/docs/install) is installed
37
and configured.
38
2. **Project Selection**: Set the active Google Cloud project:
39
40
```bash
41
gcloud config set project {project_id}
42
```
43
44
3. **API Enablement**: Ensure BigQuery and Cloud Monitoring APIs are enabled:
45
46
```bash
47
gcloud services enable bigquery.googleapis.com monitoring.googleapis.com
48
```
49
50
4. **Authentication**: Authenticate the environment:
51
* CLI commands (`bq show -j`): `gcloud auth login`
52
* SDKs and automated diagnostic scripts:
53
`gcloud auth application-default login`
54
* Service accounts: Set
55
`GOOGLE_APPLICATION_CREDENTIALS="/path/to/key.json"`
56
57
5. **Billing & IAM Roles**:
58
* Verify an active Google Cloud Billing account is attached to
59
`{project_id}`.
60
* Ensure appropriate IAM roles:
61
* `roles/bigquery.jobUser`: Executing diagnostic queries and
62
inspecting your own jobs via CLI (`bq show -j`, `bq ls -j`);
63
pair with read roles below to query `INFORMATION_SCHEMA`.
64
* `roles/bigquery.user`: Querying user-scoped job telemetry
65
(`JOBS_BY_USER`, `JOBS_TIMELINE_BY_USER`) and executing
66
diagnostic queries (supersedes `roles/bigquery.jobUser`).
67
* `roles/bigquery.metadataViewer`: Inspecting table, dataset,
68
and storage metadata (`TABLE_STORAGE`,
69
`TABLE_STORAGE_USAGE_TIMELINE`, `TABLES`,
70
`SCHEMATA_OPTIONS`).
71
* `roles/bigquery.resourceViewer` or `roles/bigquery.admin`:
72
Inspecting any user's job (`bq show -j`), project-, folder-,
73
or organization-level jobs at the matching resource scope,
74
and reservation, capacity commitment, and assignment
75
telemetry on the reservations administration project.
76
Enabling `TABLE_STORAGE` opt-in via `ALTER PROJECT` requires
77
`roles/bigquery.admin`.
78
* `roles/monitoring.viewer`: Reading Cloud Monitoring metrics.
79
* `roles/billing.viewer` (on the Cloud Billing account):
80
Viewing Cloud Billing reports and SKU cost attribution.
81
82
6. **Companion Skills Installation**:
83
This skill is part of a 3-pillar operations suite (`bigquery-observability`,
84
`bigquery-optimization`, `bigquery-troubleshooting`). If any companion skill
85
is not yet installed in your environment, install the full suite:
86
87
```bash
88
npx skills add google/skills --skill bigquery-observability --skill bigquery-optimization --skill bigquery-troubleshooting
89
```
90
91
*(If `bigquery-observability` is not installed, use the self-contained
92
baseline formulas and query templates provided directly in the reference
93
sections below).*
94
95
## Workflow
96
97
1. **Scope & Symptom Identification:** Identify the primary symptom, target
98
`project_id`, `region`, `reservation_id`, or `job_id`, and domain
99
(Performance, Compute Cost, or Storage Cost). If the request falls outside
100
incident diagnosis or asks for a sibling domain, follow **Routing
101
Boundaries** below.
102
2. **Telemetry Tool Selection:** Follow the tool-selection guidance in the
103
[BigQuery observability skill](../bigquery-observability)
104
(`bigquery_observability`) to select the appropriate telemetry interface
105
(REST API `bq show --location={location} -j {project_id}:{job_id}` for
106
single-job stage bottlenecks vs. `INFORMATION_SCHEMA` for system-wide
107
factors). Diagnostic workflows, symptom-to-cause mappings, key
108
tables/fields, CLI triage commands, and remediation levers are fully defined
109
in this skill. For pre-composed SQL query templates and full schema
110
dictionaries, consult `bigquery-observability`.
111
3. **Open-Ended Triage (Stage 1 Baseline Scan & Conversational Gate):** When
112
the user inquiry is open-ended or vague (e.g. *"Why is BigQuery slow
113
today?"* or *"Why did my bill spike?"*), execute a bounded high-level
114
baseline scan to isolate the affected domain before drilling into deep-dive
115
diagnostics:
116
* **Bounded Initial Scan:** Follow the baseline scan guidance in the
117
corresponding domain reference under **Domain References**. Ensure
118
initial queries are strictly bounded (e.g. 7-day Period-over-Period with
119
partition and job-type filters; for unspecified cost spikes, scan the 3
120
primary vectors: On-Demand TiB, Capacity slot-hours, and Storage GiB) to
121
keep diagnostic telemetry overhead minimal.
122
* **Conversational Gate:** Factually summarize high-level baseline
123
findings first and propose 2–3 focused drill-down options rather than
124
dumping downstream sub-vector queries unsolicited.
125
4. **Domain Deep Dive & Comparative Analysis:** Execute the step-by-step
126
diagnostic workflow defined in the corresponding domain reference file
127
listed under **Domain References** below, then run the corresponding query
128
from the [BigQuery observability skill](../bigquery-observability) following
129
its `INFORMATION_SCHEMA` best practices to isolate the root cause via
130
comparative analysis against a normal baseline.
131
132
## Performance Context: The Relativity of "Slow"
133
134
Performance is relative. Always approach performance troubleshooting as a
135
comparative exercise: identify a comparable past execution, compare the
136
statistics, and isolate which dimension shifted between a fast baseline and the
137
slow execution:
138
139
- **Data Processed:** Data volume increase, partition/cluster pruning changes,
140
data skew, input record amplification.
141
- **Underlying Definitions:** View changes, schema modifications.
142
- **System Contention:** Noisy neighbors, saturated capacity (>95% slot
143
utilization), idle slot availability, concurrent query spikes.
144
- **Configuration Changes:** Slot capacity/autoscale max slots changes,
145
expired capacity commitments, idle slot setting changes, or reservation
146
reassignments.
147
148
## Cost Context: The 4-Step Diagnostic Funnel
149
150
Cost troubleshooting requires tracing physical resource consumption (Slot-Hours,
151
TiB Billed, GiB Stored) rather than fluctuating contract rates:
152
153
1. **Gather:** Determine scope and pull 7-day PoP (or explicit MoM / 180-day)
154
baseline metrics.
155
2. **Isolate:** Pinpoint whether spend surged from query volume, a single
156
"Bully Query", BQML 50x multipliers, uncovered PAYG baselines, autoscaling
157
bursts, 90-day storage timer resets, or physical Fail-Safe retention drain.
158
3. **Explain:** Correlate with administrative events
159
(`INFORMATION_SCHEMA.RESERVATION_CHANGES`,
160
`INFORMATION_SCHEMA.CAPACITY_COMMITMENT_CHANGES_BY_PROJECT`,
161
`INFORMATION_SCHEMA.SCHEMATA_OPTIONS`, or actor `user_email` /
162
`query_hash`).
163
4. **Remediate:** Deliver actionable levers (partition filter enforcement,
164
query caps, commitment purchases, or Time Travel reduction).
165
166
## Domain References
167
168
### Performance Troubleshooting
169
170
- **Resource Contention & Performance Slowness**
171
(`references/performance_resource_contention.md`): Diagnostic workflows for
172
isolating single-job stage bottlenecks (`slot_contention`, `spill_to_disk`),
173
cohort baseline comparisons (`normalized_literals`), incident window
174
discovery, 1-second reservation slot saturation, timeframe contention
175
comparisons, fleet performance variance, and table-level concurrency.
176
- **Capacity & Configuration Changes**
177
(`references/performance_config_changed.md`): Diagnostic workflows for
178
auditing reservation `slot_capacity` and `autoscale.max_slots` edits,
179
tracking active capacity commitment timelines, diagnosing reservation
180
assignment modifications, and evaluating autoscaling headroom saturation.
181
- **Execution Graph & Query Plan Troubleshooting**
182
(`references/query_plan_execution_graph.md`): Diagnostic workflows for
183
investigating single-job stage bottlenecks (`bq show` point-lookups),
184
isolating slowest stages (`end_ms - start_ms`), diagnosing join explosions
185
(`records_written >> records_read`, `high_cardinality_joins`), shuffle
186
spills (`shuffle_output_bytes_spilled`), and partition skew, substep
187
intermediate variable disambiguation (`$1`, `$2`), mandatory bytes scanned
188
vs records read corrections, and UI execution graph grounding concepts.
189
190
### Cost Troubleshooting
191
192
- **On-Demand Compute Costs** (`references/cost_compute_ondemand.md`):
193
Diagnostic workflows for unpartitioned runaway scans (the "Bully Query"),
194
hidden Row-Level Security (RLS) redaction gaps, BigQuery ML (BQML) 50x model
195
training rate multipliers, and user/service account query quotas.
196
- **Capacity (Editions) Compute Costs**
197
(`references/cost_compute_capacity.md`): Diagnostic workflows for uncovered
198
baseline slot penalties (baseline > commitments), reservation baseline
199
reductions triggering autoscale surges (`RESERVATION_BASELINE_CHANGED`),
200
autoscaler thrashing from batch cron spikes, and serverless Apache Spark
201
stored procedure slot-hours.
202
- **Storage Footprint & Retention Costs** (`references/cost_storage.md`):
203
Diagnostic workflows for historical partition 90-day timer resets (the DML
204
trap), unpartitioned table active data traps, physical Time Travel and
205
Fail-Safe churn on daily overwrites, and dropped table Fail-Safe drain
206
periods.
207
208
## Routing Boundaries
209
210
If a user request shifts outside incident diagnosis during troubleshooting,
211
execute the corresponding handoff:
212
213
* **SQL Query Optimizations:** When the user asks to optimize the SQL query
214
(e.g., rewriting joins or eliminating `SELECT *`), hand off to
215
`bigquery-optimization`.
216
* **Raw Telemetry & Schema Retrieval:** When the user asks for standalone
217
`INFORMATION_SCHEMA` queries without an active performance regression or
218
incident (e.g. general telemetry queries), hand off to
219
`bigquery-observability`.
220
* **Proactive Capacity & Storage Planning:** When the user requests future
221
reservation sizing, commitment purchasing, or storage billing model
222
evaluations, hand off to `bigquery-optimization`.
223

© Google LLC · Apache 2.0 · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…