> For the complete documentation index, see [llms.txt](https://docs.onelens.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.onelens.cloud/optimize-cost-savings-and-recommendations/deep-insights/gcp-bigquery.md).

# GCP BigQuery

BigQuery shows where your BigQuery money goes: which datasets cost the most, which queries and users drive compute spend, how storage is billed, and where OneLens has found savings.

Go to **Optimize → Deep Insights → BigQuery** (under GCP). **Last Updated**, at the top right, shows when the data was last refreshed.

| Tab                  | What it answers                                                        |
| -------------------- | ---------------------------------------------------------------------- |
| Datasets             | Which datasets cost the most, split into compute and storage           |
| Reservations & Slots | <\<CONFIRM = what the Reservations & Slots tab shows>>                 |
| Top 100 Queries      | Which queries use the most resources, and which have costly patterns   |
| Top Users            | Which users and service accounts spend the most on queries             |
| Tickets              | Savings recommendations OneLens has raised on your datasets and tables |

Most tabs share the same controls: **Default View** to switch saved views, a search box, the date range, **Export**, and **Filters**.

### Where to start

To find what is driving your BigQuery cost:

1. On **Datasets**, sort by **Total Cost** and open the most expensive dataset.
2. In its **Cost & Usage Overview**, check whether compute or storage is the bigger share, and which tables and principals drive compute.
3. On **Top Users**, check whether that spend comes from people or service accounts, and whether it is rising against the previous period.
4. On **Top 100 Queries**, look for queries with **Optimization Signals**, such as unpartitioned scans.
5. On **Tickets**, act on the recommendations for those datasets and tables.

### Datasets tab

<figure><img src="https://3963693991-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiyNGpqVYfmDF6qt7Lzar%2Fuploads%2F6dtYMP3X5LWrRRLDZ3nV%2Fimage.png?alt=media&amp;token=0974bbde-2ea7-4e27-8d06-94016275fe81" alt=""><figcaption></figcaption></figure>

Four cards show **Total Datasets**, **Total BigQuery Cost**, **Compute Cost** and **Storage Cost**. Compute and storage each show their share of the total, and the two always add up to Total BigQuery Cost.

Search by dataset or project name.

| Column          | What it shows                                                                                                              |
| --------------- | -------------------------------------------------------------------------------------------------------------------------- |
| Dataset         | The dataset name, with a badge count <\<CONFIRM = what the badge next to the dataset name counts>>                         |
| Project         | The GCP project                                                                                                            |
| Location        | The dataset location, such as asia-south1 or US                                                                            |
| Storage Billing | **Logical** (billed on uncompressed bytes) or **Physical** (billed on compressed bytes)                                    |
| Compute Pricing | How queries are billed, such as On-demand                                                                                  |
| Storage Size    | Total size, split into active and long-term (LT) storage                                                                   |
| Compute Cost    | Query cost for the period                                                                                                  |
| Storage Cost    | Storage cost for the period                                                                                                |
| Total Cost      | Compute Cost plus Storage Cost for the selected date range                                                                 |
| Prev Cost       | Total cost for the previous period of the same length. If the range is 15 Sep to 14 Oct, Prev Cost covers 16 Aug to 14 Sep |

### Dataset details

Click a dataset to open it. Four cards show **Last 30 Days Cost**, **Compute Cost** and **Storage Cost** (each with its share), and the number of **Tables**. The page has four tabs: **Dataset Details**, **Cost History**, **Cost & Usage Overview** and **Tickets**.

#### Dataset Details

<figure><img src="https://3963693991-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiyNGpqVYfmDF6qt7Lzar%2Fuploads%2F20xFsCKZAid0IyibIiTG%2Fimage.png?alt=media&amp;token=970f05ea-70ea-4ad3-a933-1080b844a386" alt=""><figcaption></figcaption></figure>

| Section                     | What it shows                                                                                                  |
| --------------------------- | -------------------------------------------------------------------------------------------------------------- |
| Resource Information        | Project, dataset ID, location, creation date, default table expiration, default partition expiration, and CMEK |
| Table Inventory by Type     | Count and size of standard, partitioned, clustered, and partitioned + clustered tables, plus clones and views  |
| Top 5 Tables by 30-Day Cost | Each table's cost, size and type, and how many times it was queried in the last 30 days                        |

Table Inventory by Type helps you spot large standard tables. These tables have no partitioning or clustering, so a query that filters on a date or key still scans the whole table.

#### Cost & Usage Overview

<figure><img src="https://3963693991-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiyNGpqVYfmDF6qt7Lzar%2Fuploads%2FLSBwOE6G4x64E18c1lWO%2Fimage.png?alt=media&amp;token=07c0a4fd-9636-4a62-96c7-a5a9c5e1d926" alt=""><figcaption></figcaption></figure>

Pick a date range. Each row shows its **Attribution**, **Cost** and **Volume**.

| Component                      | What it shows                                                                                                                                                                                            |
| ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Query Compute (Analysis)       | Query cost split by the table queried, with data billed and number of runs. The heading shows the rate, for example $5.99/TiB billed. Smaller tables are grouped into one row, such as "Other 86 tables" |
| Query Compute - Top Principals | The same query cost split by who ran the queries, tagged **Human** or **Service Account**. Smaller principals are grouped into one row                                                                   |
| Storage                        | Active and long-term storage cost, with the rate per GiB-month. The heading shows the billing model, such as Physical Billing Model                                                                      |

Total Cost is query compute plus storage. Top Principals shows the same compute cost from another angle, so it is not added again.

#### Tickets

The **Tickets** tab lists the tickets raised on this dataset.

### Top 100 Queries tab

This tab lists the 100 queries that use the most resources in the selected period.

<figure><img src="https://3963693991-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiyNGpqVYfmDF6qt7Lzar%2Fuploads%2FARTNfiq4kelanzOwRZO7%2Fimage.png?alt=media&amp;token=b0508f7e-bb7f-4def-8dba-6cffc6fa633f" alt=""><figcaption></figcaption></figure>

Use **Top 100 By** to choose how queries are ranked, for example by **Slot Hours**. Search by query fingerprint, query text or principal.

Four cards summarise the top 100:

| Card                                | What it shows                                          |
| ----------------------------------- | ------------------------------------------------------ |
| Total Query Runs (Top 100)          | How many times these queries ran in total              |
| Unique Query Fingerprints (Top 100) | How many distinct queries are in the list              |
| Total Query Cost (Top 100)          | What these queries cost                                |
| Queries with Bad Signals (Top 100)  | How many of them have at least one optimization signal |

Each row is one query fingerprint. A fingerprint groups repeated runs of the same query, so **Runs** shows how often that query ran.

| Column               | What it shows                                                                                            |
| -------------------- | -------------------------------------------------------------------------------------------------------- |
| Query Fingerprint    | The ID that groups runs of the same query                                                                |
| Preview              | The start of the query and its statement type, such as INSERT. Open it to see a sample of the full query |
| Principal            | Who ran the query, tagged Human or Service Account                                                       |
| Runs                 | Number of runs in the period                                                                             |
| Bytes Scanned        | Total data scanned, and the average per run                                                              |
| Slot Time            | Total slot hours used                                                                                    |
| Cost                 | What the query cost. <\<CONFIRM = why some queries show "--" for Cost>>                                  |
| Cache Hit            | The share of runs answered from BigQuery's cache                                                         |
| Optimization Signals | Costly patterns OneLens found in the query                                                               |

<figure><img src="https://3963693991-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiyNGpqVYfmDF6qt7Lzar%2Fuploads%2FPB33nzpJ3T8HhxHGNS8k%2Fimage.png?alt=media&amp;token=dc1166eb-2614-4b6c-ace2-d02699ec2f86" alt=""><figcaption></figcaption></figure>

#### Optimization signals

| Signal             | What it means                                                           | What to do                                             |
| ------------------ | ----------------------------------------------------------------------- | ------------------------------------------------------ |
| SELECT \*          | The query reads every column, so it scans more data than it needs       | Select only the columns you use                        |
| Unpartitioned scan | The query scans a table without using partitions to limit the data read | Partition the table, or filter on the partition column |

### Top Users tab

This tab ranks every user and service account that ran queries in the period.

<figure><img src="https://3963693991-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiyNGpqVYfmDF6qt7Lzar%2Fuploads%2FNOx6Hs4h3nJncq3lE73E%2Fimage.png?alt=media&amp;token=30c2f921-e38a-41d3-829a-3f3235f483b2" alt=""><figcaption></figcaption></figure>

Search by principal, domain or project. Four cards show **Active Principals**, split into **Service Accounts** and **Human Users**, and **Total Query Cost**.

| Column           | What it shows                                                                                                        |
| ---------------- | -------------------------------------------------------------------------------------------------------------------- |
| Principal        | The user or service account                                                                                          |
| Type             | Human or Service Account                                                                                             |
| Location         | Where the queries ran                                                                                                |
| Project (Origin) | The project the queries ran from                                                                                     |
| Queries          | Number of queries in the selected range. <\<CONFIRM = what the "Data Transfer" label under some query counts means>> |
| Bytes Scanned    | Total data scanned, and the average per query                                                                        |
| Cache Hit        | The share of queries answered from cache                                                                             |
| Cost             | Query cost for the selected range                                                                                    |
| Delta vs Prev    | The change in cost from the previous period                                                                          |
| Top Dataset      | The principal's top dataset <\<CONFIRM = what Top Dataset is ranked by>>                                             |

Sort by **Cost** or check **Delta vs Prev** to find the principals whose query spend is largest or growing fastest.

### Tickets tab

<figure><img src="https://3963693991-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiyNGpqVYfmDF6qt7Lzar%2Fuploads%2FJ7YuN9WPebhWGmTkhzUo%2Fimage.png?alt=media&amp;token=e23a9ef9-f68b-4cee-9dba-103dda57f66a" alt=""><figcaption></figcaption></figure>

Two cards show **Total Tickets** and **Potential Savings (Up-To)**.

| Column                | What it shows                                                                      |
| --------------------- | ---------------------------------------------------------------------------------- |
| ID                    | The ticket ID, such as CP\_18962                                                   |
| Recommendation Entity | The dataset or table the recommendation applies to                                 |
| Status                | The ticket status, such as To-Do or Pending Verification. Change it from the table |
| Policy / Rule         | The policy that raised the ticket                                                  |
| Assigned To           | Who owns the ticket. Change it from the table                                      |
| Potential Savings     | Estimated savings if you act on the recommendation                                 |
| Recommendation        | What to do                                                                         |

Search by ticket ID, choose which **Columns** to show, **Export** the list, or narrow it with **Filters**. When you mark a ticket as resolved, it moves to **Pending Verification** while OneLens checks the change was made.

Examples of what BigQuery tickets flag:

| What it flags                                                       | Recommendation                                                     |
| ------------------------------------------------------------------- | ------------------------------------------------------------------ |
| Datasets that compress well but use logical storage billing         | Switch the dataset to physical storage billing                     |
| Partitioned tables with no partition expiration                     | Set a partition expiration that matches how long you need the data |
| Partitioned tables scanned without a filter on the partition column | Add a predicate on the partitioning column                         |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.onelens.cloud/optimize-cost-savings-and-recommendations/deep-insights/gcp-bigquery.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
