Request a demo

Public dataset · Web, code and analytics

Stack Overflow in BigQuery

The stackoverflow dataset is a snapshot of Stack Overflow questions, answers, comments, users, votes and tags, last updated in November 2022 and no longer refreshed. The questions table is 37 GiB, mostly the body column, so selecting only titles, tags and scores cuts a scan to about 2.5 GiB.

bigquery-public-data.stackoverflow · Stack Overflow · US · Sizes measured November 23, 2026

16tables
237 GiBlogical size
637,122,277rows
$1.45to scan every column once, on-demand

bigquery-public-data.stackoverflow contains the public content of Stack Overflow. The dataset description gives 2022-11-25 as the last data update and says the dataset is no longer actively updated, so nothing after November 2022 is in it.

Questions and answers live in separate tables: posts_questions and posts_answers. An answer points to its question through parent_id, and a question points to its accepted answer through accepted_answer_id. comments, votes, badges, post_links and post_history (every revision of every post, the largest table at 113 GiB) complete the activity data, and users holds profiles with reputation. Tags on a question are one string separated by |, for example python|pandas; the tags table has one row per tag with its question count.

stackoverflow_posts is an older combined table last modified in 2017. Its description says not to use it and to use the posts_* tables instead. No table is partitioned or clustered.

Tables and sizes

TableRowsSizeFull scanLayout
post_history
Every revision of every post.
152,435,941113 GiB$0.69None
posts_questions
Questions, with title, body, tags and scores.
23,020,12737.2 GiB$0.23None
stackoverflow_posts
Old combined posts table from 2017. Its description says to use the posts_* tables instead.
31,017,88929.4 GiB$0.18None
posts_answers
Answers. `parent_id` is the question id.
34,024,11928.6 GiB$0.17None
comments86,754,11116.0 GiB$0.10None
votes236,452,8857.0 GiB$0.04None
users18,712,2123.1 GiB$0.02None
badges46,135,3862.0 GiB$0.01None
post_links
Links between posts, such as duplicates.
8,395,210320 MiBunder $0.01None
posts_tag_wiki55,11336.0 MiBunder $0.01None
posts_tag_wiki_excerpt55,11510.9 MiBunder $0.01None
tags
One row per tag with the number of questions.
63,6532.5 MiBunder $0.01None
posts_moderator_nomination342470 KiBunder $0.01None
posts_orphaned_tag_wiki16752.1 KiBunder $0.01None
posts_wiki_placeholder55.0 KiBunder $0.01None
posts_privilege_wiki23.4 KiBunder $0.01None

Full scan = every column of the table at the on-demand list price of $6.25 per TiB, before your free TiB each month. Selecting fewer columns costs proportionally less. See BigQuery pricing.

Example queries

Most used tags

Scans 1.3 MiB · under $0.01 on-demand

The tags table already holds the count per tag, so this reads about 1 MiB instead of splitting the tags string of 23 million questions.

SELECT tag_name, count AS questions
FROM `bigquery-public-data.stackoverflow.tags`
ORDER BY count DESC
LIMIT 20;

BigQuery questions per year, and how many went unanswered

Scans 955 MiB · under $0.01 on-demand

SPLIT turns the |-separated tag string into an array, so IN UNNEST matches the exact tag and not tags that merely contain the word.

SELECT
  EXTRACT(YEAR FROM creation_date) AS year,
  COUNT(*) AS questions,
  COUNTIF(answer_count = 0) AS unanswered
FROM `bigquery-public-data.stackoverflow.posts_questions`
WHERE 'google-bigquery' IN UNNEST(SPLIT(tags, '|'))
GROUP BY year
ORDER BY year;

Top-voted BigQuery questions with SELECT * (expensive)

Scans 37.2 GiB · $0.23 on-demand

SELECT * pulls the body column, which holds the full HTML of every question. The filter does not help, because the table is not partitioned or clustered.

SELECT *
FROM `bigquery-public-data.stackoverflow.posts_questions`
WHERE 'google-bigquery' IN UNNEST(SPLIT(tags, '|'))
ORDER BY score DESC
LIMIT 20;

The same question, selecting only the columns you need

Scans 2.5 GiB · $0.02 on-demand

Same rows, about 15 times fewer bytes. Fetch the body later for the handful of ids you care about.

SELECT id, title, score, view_count, answer_count
FROM `bigquery-public-data.stackoverflow.posts_questions`
WHERE 'google-bigquery' IN UNNEST(SPLIT(tags, '|'))
ORDER BY score DESC
LIMIT 20;

Fastest first answers to BigQuery questions in 2022

Scans 2.7 GiB · $0.02 on-demand

Joins answers to questions on parent_id and keeps the earliest answer per question. Neither body column is read.

SELECT
  q.id,
  q.title,
  TIMESTAMP_DIFF(MIN(a.creation_date), q.creation_date, MINUTE) AS minutes_to_first_answer
FROM `bigquery-public-data.stackoverflow.posts_questions` AS q
JOIN `bigquery-public-data.stackoverflow.posts_answers` AS a
  ON a.parent_id = q.id
WHERE 'google-bigquery' IN UNNEST(SPLIT(q.tags, '|'))
  AND EXTRACT(YEAR FROM q.creation_date) = 2022
GROUP BY q.id, q.title, q.creation_date
ORDER BY minutes_to_first_answer
LIMIT 20;

Querying it cheaply

  • The body columns of posts_questions and posts_answers hold most of their bytes. SELECT * on questions reads 37 GiB, while id, title, scores and tags read about 2.5 GiB.
  • No table is partitioned or clustered. A filter on creation_date or on a tag returns fewer rows but reads the same bytes.
  • Skip post_history (113 GiB) unless you need edit history, and skip stackoverflow_posts, which is outdated.
  • For per-tag counts, read the 2.5 MiB tags table instead of splitting the tag string of every question.
  • The data stopped changing in 2022, so query results are cached for repeated identical queries, and a slice you use often can be saved to your own table once with CREATE TABLE AS SELECT.

FAQ

How much does it cost to query the Stack Overflow dataset?

Most questions about tags, scores and dates read 1 to 3 GiB, far inside the free 1 TiB a month. SELECT * on posts_questions reads 37 GiB, and the whole dataset is about 237 GiB. At $6.25 per TiB on-demand, even a full scan of posts_questions costs about $0.23.

Is the Stack Overflow BigQuery dataset free?

Yes for storage: the table sits in the bigquery-public-data project and Google pays to store it. You pay for the queries you run from your own project. On-demand, the first 1 TiB scanned each month is free, then you pay per TiB scanned (see BigQuery pricing).

Is the Stack Overflow dataset still updated?

No. Its description says it is no longer actively updated, and the last data update is 2022-11-25. Questions and answers posted after that date are not in it.

How do I filter Stack Overflow questions by tag in BigQuery?

Tags are stored as one string such as python|pandas. Use 'pandas' IN UNNEST(SPLIT(tags, '|')) for an exact tag match. tags LIKE '%pandas%' also matches tags like pandas-groupby.

All public datasets · BigQuery cost queries · Pricing calculator

Cut BigQuery spend without guessing

Masthead attributes compute and storage cost to every project, user, pipeline and table, finds unused and dead-end tables, and shows where editions or on-demand pricing is cheaper. Mnemonic cut its BigQuery compute cost by 20% within 24 hours of onboarding.