Docs/Metadata and operations/INFORMATION_SCHEMA
Metadata and operationsOperations

INFORMATION_SCHEMA in BigQuery

INFORMATION_SCHEMA views describe tables, columns, partitions, jobs and storage, queried with SQL. Two ready-to-run queries for storage and compute cost, the columns people mix up, and what job history can't see when you look for unused tables.

Practice this in free lessons on learn.querylab.io: INFORMATION_SCHEMA: how a table is stored and 2 more.

INFORMATION_SCHEMA is a set of read-only views that describe your BigQuery objects: datasets, tables, columns, partitions, views, routines, jobs, reservations and storage. You query them with ordinary SQL, which makes them the way to answer questions like “which tables have a column called email”, “which partitions changed today” or “who ran the most expensive queries this week”.

Columns that are easy to mix up

Google documents about 70 of these views, and many columns have similar names. Each mix-up below runs without an error and returns a plausible number:

QuestionUseEasy to pick insteadWhat goes wrong
Jobs from last weekcreation_timestart_timeSame rows, but it reads the whole 180 days of history (measured below)
What a query costtotal_bytes_billedtotal_bytes_processedProcessed skips the 10 MB minimum per table
Total spendstatement_type IS DISTINCT FROM 'SCRIPT'no filterA script’s parent job repeats its children’s totals, so everything in a script counts twice
Only queriesjob_type = 'QUERY'statement_typestatement_type says what kind of query. It is NULL for load and copy jobs and for failed jobs
Size of a tableone of logical or physicalthe two added togetherThe same data counted twice

The script row is easy to check. We ran a two-statement script: each child job billed 10,485,760 bytes and the parent billed 20,971,520.

Dataset or region

Every view must be qualified. Most table-level views take a dataset, and return metadata for that dataset only:

the tables of bigquery-public-data.samples
123
SELECT table_name, table_type, DATE(creation_time) AS created
FROM `bigquery-public-data.samples.INFORMATION_SCHEMA.TABLES`
ORDER BY table_name
Result in BigQuery
Rowtable_nametable_typecreated
1github_nestedBASE TABLE2016-03-14
2github_timelineBASE TABLE2016-03-14
3gsodBASE TABLE2016-03-14
4natalityBASE TABLE2016-03-14
5shakespeareBASE TABLE2016-03-14
6trigramsBASE TABLE2016-03-14
7wikipediaBASE TABLE2016-03-14
7 rows

Views about the whole project, like JOBS and SCHEMATA, take a region qualifier instead: `region-us`.INFORMATION_SCHEMA.JOBS. A region qualifier covers one location only. region-us is the US multi-region and doesn’t include us-central1 or other single US regions; query each location separately.

The views that accept a dataset qualifier are TABLES, TABLE_OPTIONS, COLUMNS, COLUMN_FIELD_PATHS, PARTITIONS, VIEWS, MATERIALIZED_VIEWS, ROUTINES, ROUTINE_OPTIONS and PARAMETERS. Most of them also accept a region, which then returns that view across every dataset of the project in the region. PARTITIONS and the search index views take a dataset only.

The name is case-sensitive

INFORMATION_SCHEMA and the view name must be in upper case. In lower case, BigQuery reads information_schema as an ordinary dataset name and looks for a dataset of that name:

information_schema.tables in lower caseBigQuery rejects this query
12
SELECT table_name
FROM `bigquery-public-data.samples.information_schema.tables`
BigQuery dry run

Not found: Dataset bigquery-public-data:samples.information_schema was not found in location US

Columns and nested fields

COLUMNS has one row per top-level column:

the columns of samples.shakespeare
1234
SELECT column_name, data_type, is_nullable
FROM `bigquery-public-data.samples.INFORMATION_SCHEMA.COLUMNS`
WHERE table_name = 'shakespeare'
ORDER BY ordinal_position
Result in BigQuery
Rowcolumn_namedata_typeis_nullable
1wordSTRINGNO
2word_countINT64NO
3corpusSTRINGNO
4corpus_dateINT64NO
4 rows

is_nullable is the string 'YES' or 'NO'. data_type is the full type, like ARRAY<STRUCT<sku STRING, qty INT64>>. For the fields inside structs, use COLUMN_FIELD_PATHS, which has one row per field path:

fields of the repository struct in samples.github_nested
12345
SELECT field_path, data_type
FROM `bigquery-public-data.samples.INFORMATION_SCHEMA.COLUMN_FIELD_PATHS`
WHERE table_name = 'github_nested' AND field_path LIKE 'repository.%'
ORDER BY field_path
LIMIT 6
Result in BigQuery
Rowfield_pathdata_type
1repository.created_atSTRING
2repository.descriptionSTRING
3repository.forkBOOL
4repository.forksINT64
5repository.has_downloadsBOOL
6repository.has_issuesBOOL
6 rows

To find every table in a dataset that has a column, search COLUMNS by column_name, or COLUMN_FIELD_PATHS by field_path to include nested fields:

every column with year in its name
12345
SELECT table_name, column_name, data_type
FROM `bigquery-public-data.samples.INFORMATION_SCHEMA.COLUMNS`
WHERE LOWER(column_name) LIKE '%year%'
ORDER BY table_name, column_name
LIMIT 8
Result in BigQuery
Rowtable_namecolumn_namedata_type
1gsodyearINT64
2natalitysource_yearINT64
3natalityyearINT64
3 rows

What costs money, and who reads it?

This query lists your tables by storage cost, prices each one under both billing models, and shows when a query last read it. Change the DECLARE lines to your own rates: these are the us-central1 ones from Storage pricing. Replace region-us with your region.

DECLARE active_logical FLOAT64 DEFAULT 0.023;
DECLARE long_term_logical FLOAT64 DEFAULT 0.016;
DECLARE active_physical FLOAT64 DEFAULT 0.04;
DECLARE long_term_physical FLOAT64 DEFAULT 0.02;
DECLARE lookback_days INT64 DEFAULT 90;

WITH reads AS (
  SELECT ref.project_id, ref.dataset_id, ref.table_id, MAX(creation_time) AS last_read
  FROM `region-us`.INFORMATION_SCHEMA.JOBS_BY_PROJECT, UNNEST(referenced_tables) AS ref
  WHERE creation_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL lookback_days DAY)
    AND job_type = 'QUERY'
    AND error_result IS NULL
    AND NOT (ref.dataset_id = IFNULL(destination_table.dataset_id, '')
      AND ref.table_id = IFNULL(destination_table.table_id, ''))
  GROUP BY 1, 2, 3
)
SELECT
  s.table_schema AS dataset,
  s.table_name,
  IFNULL(o.option_value, 'LOGICAL') AS billing_model,
  ROUND(s.active_logical_bytes / POW(1024, 3) * active_logical
    + s.long_term_logical_bytes / POW(1024, 3) * long_term_logical, 2) AS logical_usd,
  ROUND((s.active_physical_bytes + s.fail_safe_physical_bytes) / POW(1024, 3) * active_physical
    + s.long_term_physical_bytes / POW(1024, 3) * long_term_physical, 2) AS physical_usd,
  MAX(r.last_read) AS last_read
FROM `region-us`.INFORMATION_SCHEMA.TABLE_STORAGE_BY_PROJECT AS s
LEFT JOIN `region-us`.INFORMATION_SCHEMA.SCHEMATA_OPTIONS AS o
  ON o.schema_name = s.table_schema AND o.option_name = 'storage_billing_model'
LEFT JOIN reads AS r
  ON r.project_id = s.project_id
  AND r.dataset_id = s.table_schema
  AND (r.table_id = s.table_name
    OR (ENDS_WITH(r.table_id, '*') AND STARTS_WITH(s.table_name, RTRIM(r.table_id, '*'))))
WHERE s.table_type = 'BASE TABLE' AND NOT s.deleted
GROUP BY ALL
ORDER BY logical_usd DESC
LIMIT 100;

On one of our projects, the largest table priced at $9.61 logical and $2.77 physical, and its dataset already uses physical billing. When a dataset on logical billing shows a gap like that, look at switching. A large table with a NULL last_read is the one to ask about, but read the next section first.

active_physical_bytes already includes time travel bytes, which is why the query adds only fail-safe bytes to it. The figures are today’s bytes, and your bill is bytes over time. Storage pricing covers the view that records usage over time.

What job history can’t see

A NULL last_read means no job in this project recorded a read. That isn’t the same as “nobody uses this table”. We ran each of these and read back what JOBS_BY_PROJECT stored:

What we didWhat referenced_tables heldWhat it does to an unused-tables report
SELECT from a view, or a view of a viewthe base table only, never the viewEvery view looks unused
SELECT from `events_*`the literal name events_*Shards never match by name
INSERT ... VALUES, TRUNCATE TABLEthe target tableA table that is only written to looks read
A query answered from the cachenothingThe read isn’t counted
A scriptnothing on the parent, the tables on each childFine, as long as you read the children
A copy jobnothingThe read isn’t counted
bq head, which reads with tabledata.listno job at allThe read isn’t counted
A dry runno job at allCorrect, because nothing was read
A query run and billed from another projectno row in this project’s historyThe read isn’t counted

The query above handles two of these. It drops rows where the referenced table is also the job’s destination, which removes plain writes, and it matches events_* against each shard by prefix. Both have a cost. A MERGE or INSERT ... SELECT that reads its own target no longer counts as a read, and a wildcard read marks every shard as read even when _TABLE_SUFFIX picked one.

The wildcard case matters because sharded tables are listed one row per shard. The public Google Analytics sample holds one logical table as 366 tables:

one table family, 366 rows in TABLES
12345678
SELECT
  REGEXP_REPLACE(table_name, r'\d{8}$', '*') AS table_family,
  COUNT(*) AS shards,
  MIN(table_name) AS first_shard,
  MAX(table_name) AS last_shard
FROM `bigquery-public-data.google_analytics_sample.INFORMATION_SCHEMA.TABLES`
GROUP BY table_family
ORDER BY shards DESC, table_family
Result in BigQuery
Rowtable_familyshardsfirst_shardlast_shard
1ga_sessions_*366ga_sessions_20160801ga_sessions_20170801
2Google-ecommerce-dataset-table1Google-ecommerce-dataset-tableGoogle-ecommerce-dataset-table
3daily_total_visits1daily_total_visitsdaily_total_visits
4daily_visits1daily_visitsdaily_visits
4 rows

Three limits remain. History goes back 180 days, so a table read once a year can look dead. The view covers one project and one region. To see reads from other projects, use JOBS_BY_ORGANIZATION if you have access to it. Views have no read history here at all, so check what depends on a table by searching their SQL before you drop it:

SELECT table_name
FROM mydataset.INFORMATION_SCHEMA.VIEWS
WHERE view_definition LIKE '%orders%';

For reads that never become a query job, use audit logs. Before you delete anything, a snapshot keeps the way back open.

Where the compute money goes

query_info.query_hashes.normalized_literals is BigQuery’s own fingerprint of a query. It ignores comments, parameter values and literals, so WHERE day = '2026-01-01' and WHERE day = '2026-06-15' group together. This query ranks query shapes by cost, and shows each one under on-demand and slot pricing:

DECLARE on_demand_per_tib FLOAT64 DEFAULT 6.25;
DECLARE enterprise_per_slot_hour FLOAT64 DEFAULT 0.06;
DECLARE lookback_days INT64 DEFAULT 30;

SELECT
  query_info.query_hashes.normalized_literals AS query_hash,
  SUBSTR(ANY_VALUE(query HAVING MAX total_bytes_billed), 1, 500) AS costliest_run,
  CASE
    WHEN EXISTS (SELECT 1 FROM UNNEST(labels) WHERE key = 'dbt_invocation_id') THEN 'dbt'
    WHEN ENDS_WITH(user_email, 'gserviceaccount.com') THEN 'service account'
    ELSE 'person'
  END AS source,
  COUNT(*) AS runs,
  COUNT(DISTINCT user_email) AS users,
  ROUND(SUM(total_bytes_billed) / POW(1024, 4) * on_demand_per_tib, 2) AS on_demand_usd,
  ROUND(SUM(total_slot_ms) / 3600000, 1) AS slot_hours,
  ROUND(SUM(total_slot_ms) / 3600000 * enterprise_per_slot_hour, 2) AS enterprise_usd_floor
FROM `region-us`.INFORMATION_SCHEMA.JOBS_BY_PROJECT
WHERE creation_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL lookback_days DAY)
  AND job_type = 'QUERY'
  AND state = 'DONE'
  AND statement_type IS DISTINCT FROM 'SCRIPT'
  AND query_info.query_hashes.normalized_literals IS NOT NULL
GROUP BY query_hash, source
ORDER BY on_demand_usd DESC
LIMIT 50;

Replace the slot rate if you are on another edition: at the time of writing the US rates are $0.04 for Standard, $0.06 for Enterprise and $0.10 for Enterprise Plus. enterprise_usd_floor is a floor because total_slot_ms counts the slots a query used. An autoscaling reservation bills the slots it scaled to, in multiples of 50, and holds them for at least 60 seconds unless you opt in to fluid scaling (see Slots).

The hash only exists for successful GoogleSQL queries that didn’t hit the cache, so the filter also removes failures and cached runs. Those aren’t billed by the byte. It can change for the same text when an underlying view changes, or when a schema change alters what SELECT * expands to.

The CASE only names what we could confirm. dbt adds a dbt_invocation_id label to its jobs. Other tools add their own labels, and the quickest way to learn yours is to list them with SELECT l.key, COUNT(*) ... UNNEST(labels) AS l GROUP BY 1. To rank by person, group by user_email in place of query_hash.

In Querylab.io, History Optimize runs this kind of grouping over your job history and shows the math for each figure. For more single-purpose queries, see Monitoring jobs and costs.

A view for each question

ViewScopeUse it to
TABLES, TABLE_OPTIONSdataset or regionlist tables, see their type, DDL (ddl column), expiration and labels
COLUMNS, COLUMN_FIELD_PATHSdataset or regionfind columns and their types
PARTITIONSdatasetsee each partition’s rows, bytes and last change
TABLE_STORAGEregionlogical, physical, active, long-term and time travel bytes per table
JOBS (JOBS_BY_PROJECT), JOBS_BY_USERregionjob history: who ran what, bytes billed, slot time, errors
JOBS_TIMELINEregionslot use per second, for capacity planning
VIEWS, ROUTINESdataset or regionthe SQL of views and functions
TABLE_CONSTRAINTS, KEY_COLUMN_USAGEdatasetprimary and foreign keys
SESSIONS_BY_USER, STREAMING_TIMELINE, RESERVATIONSregionsessions, streaming volume, reservations
OBJECT_PRIVILEGESregionwho has access to one dataset or table (the WHERE must name it)
RECOMMENDATIONSregionGoogle’s partitioning and clustering suggestions, with estimated savings

The ddl column of TABLES holds the CREATE TABLE statement that recreates the table, column descriptions included, which is the quickest way to copy a schema with its options:

the statement that recreates samples.shakespeare
123
SELECT ddl
FROM `bigquery-public-data.samples.INFORMATION_SCHEMA.TABLES`
WHERE table_name = 'shakespeare'
Result in BigQuery
Rowddl
1CREATE TABLE `bigquery-public-data.samples.shakespeare` ( word STRING NOT NULL OPTIONS(description="A single unique word (where whitespace is the delimiter) extracted from a corpus."), word_count INT64 NOT NULL OPTIONS(description="The number of times this word appears in this corpus."), corpus STRING NOT NULL OPTIONS(description="The work from which this word was extracted."), corpus_date INT64 NOT NULL OPTIONS(description="The year in which this corpus was published.") );
1 row

In Querylab.io, right-click a table and choose SQL Templates, then CREATE TABLE, to get that statement. Right-click a project for the Information Schema Recipes, ten cost and hygiene queries written for the project’s region (see DDL operations). Storage statistics show what TABLE_STORAGE holds for a project, dataset or table, priced under both billing models.

What it costs

With on-demand pricing, every INFORMATION_SCHEMA query is billed at least 10 MB, even when it reads less. A dry run already shows that number:

the estimate for a small metadata query
12
SELECT table_name
FROM `bigquery-public-data.samples.INFORMATION_SCHEMA.TABLES`
BigQuery dry run

This query will process 10.0 MB when run.

Results are never cached, so each run is billed again, even with the same text. That is a fraction of a cent per query, but a dashboard that polls JOBS every minute adds up. Large JOBS queries over long time ranges can read far more than 10 MB; filter on creation_time, the view’s partitioning column.

The filter has to be on creation_time. start_time and end_time look like they would do the same, but they don’t prune. We dry-ran three queries on one project’s `region-us`.INFORMATION_SCHEMA.JOBS_BY_PROJECT:

FilterBytes processed
none106,579,826
creation_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 DAY)1,308,333
start_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 DAY)106,579,826

The start_time filter returns the same rows as it would otherwise, but reads the whole history. The 1.3 MB case is still billed as 10 MB, as above, so on a small project the bill is the same and only the processed bytes show it. The gap is in the bytes a large project scans. The numbers are from our project and will differ on yours.

Storage billing model and TABLE_STORAGE

A dataset’s storage billing model is one of its options, and SCHEMATA_OPTIONS lists it:

SELECT schema_name, option_value
FROM `region-us`.INFORMATION_SCHEMA.SCHEMATA_OPTIONS
WHERE option_name = 'storage_billing_model';

A dataset that uses physical billing has a row with PHYSICAL. A dataset that was never switched has no row at all, not a row with LOGICAL or NULL. On our project, one dataset had a storage_billing_model row, and every other dataset was missing from the result. Read “no row” as logical billing, the default. To list every dataset with its model, LEFT JOIN from SCHEMATA and use COALESCE(option_value, 'LOGICAL').

TABLE_STORAGE has both logical and physical byte columns for every table, whichever model the dataset uses. You are billed on one set, chosen by the dataset’s model. Adding total_logical_bytes and total_physical_bytes counts the same data twice. Google’s forecast formulas use the logical columns for a logical dataset and the physical ones for a physical dataset. See Storage pricing for a query that prices both.

Permissions

You see metadata only for objects you have access to: a dataset qualifier needs permissions on the dataset, a region qualifier on the project. JOBS_BY_USER shows your own jobs; JOBS for the whole project needs bigquery.jobs.listAll, which comes with the BigQuery Resource Viewer role. TABLE_STORAGE needs bigquery.tables.get and bigquery.tables.list, which the BigQuery Metadata Viewer role has.

Open the playground. It is the real app on public datasets and needs no sign-in.