Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8087507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:47:52+00:00 2026-06-05T18:47:52+00:00

I have a dataset with ~20M rows and I’m observing the following behavior. The

  • 0

I have a dataset with ~20M rows and I’m observing the following behavior.

The query below returns the error “Response too large to return”. The ‘id’ field is shared among multiple records and the ‘field’ field has some arbitrary value for each record. I would expect that the result set should only contain 10 rows, well below the query response limit.

SELECT id, COUNT(DISTINCT field)
FROM [my.dataset]
GROUP BY id
LIMIT 10

However, when the DISTINCT keyword is removed from the COUNT aggregation function, BigQuery returns 10 results as expected.

SELECT id, COUNT(field)
FROM [my.dataset]
GROUP BY id
LIMIT 10

I don’t understand why the first query returns an error and the second completes successfully. Shouldn’t both queries return the same number of rows?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T18:47:54+00:00Added an answer on June 5, 2026 at 6:47 pm

    It’s not the result size that is causing this response, it’s the intermediate size of the data generated by your COUNT DISTINCT query.

    Note: COUNT DISTINCT returns a statistical approximation after 1000 values – you can alter the approximation by choosing a particular value for the limit in which DISTINCT will return an approximation.. such as: COUNT(DISTINCT your_field, 500)

    See: https://developers.google.com/bigquery/docs/query-reference#aggfunctions

    This behavior is due to the design of BigQuery, which makes it so quick: data is queried via separate nodes, and results are aggregated at mixers. A COUNT will tally the total number of results and combine the answer, but COUNT DISTINCT needs to keep track of potentially millions of separate sums, and then combine those values later. Therefore a COUNT DISTINCT can create a lot of data, and could potentially be over internal maximum for individual nodes.

    Note also that currently, BigQuery LIMIT clauses are applied after the entire result set is determined.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dataset consisting of a large collection of points in three dimensional
I have a dataset that returns questions and answers from the database, each answer
I have DataSet. it returns date, and value by date. for ex: 01.01.2009 454
i have dataset in my C# program and i try to run query DataRow[]
I have a dataset (called dataSet below) with a single table and some records
I have a dataset, How can I use the below code to bind the
I have a DataSet where I need to find out how many rows has
I have a dataset in MySQL where using limit is already an expensive query,
i have dataset that contain data. i need to run any query on this
I have a dataset with the following variables: condition: 1,2,3 type: friend, foe Proportion_Choosing_Message:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.