Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resources exceeded BigQuery

When running the following query I got the error:

Resources exceeded during query execution: The query could not be executed in the allotted memory. Peak usage: 158% of limit. Top memory consumer(s): sort operations used for analytic OVER() clauses: 98% other/unattributed: 2%

select *, row_number() over(PARTITION BY Column_A ORDER BY Column_B)
from
(SELECT
*
FROM
  Table_1 UNION ALL
SELECT
  *
FROM
  Table_2 UNION ALL
SELECT
  *
FROM
  Table_3
)

Can someone help me how to change this query or is there possibility that we can change the memory limit in bigquery?

like image 388
Aaron_ Avatar asked Dec 12 '18 06:12

Aaron_


People also ask

How many rows can a BigQuery table have?

Maximum of 100,000 rows - BigQuery datasets exceeding the maximum number of rows will be truncated. Partitioned tables are not supported - Any BigQuery tables that have partitioned columns will report an error during configuration in AppSheet.

Does BigQuery have quota for update?

BigQuery generally does not limit the number of concurrent INSERT DML statements that write to a single table.

Does BigQuery handle unstructured data?

Directly process unstructured data using BigQuery ML Object tables contain metadata such as URI (Uniform Resource Identifier), content type, and size that can be queried just like other BigQuery tables. You can then derive inferences using machine learning models on unstructured data with BigQuery ML.


2 Answers

Welcome Aaron,

This error means BigQuery is unable to process the whole query due to memory limits, the ORDER BY function is pretty memory intensive, try removing it and I would expect your query to run fine.

If you need results ordered, try writing the unordered query out to a table then running a new query on this table to order the results.

If you're interested. here's an interesting article on how and BigQuery executes in memory: https://cloud.google.com/blog/products/gcp/in-memory-query-execution-in-google-bigquery

I don't believe you can override or change this memory limit, but happy to be proven wrong.

like image 142
Ben P Avatar answered Oct 15 '22 07:10

Ben P


Make sure your ORDER BY is being executed in real last step, additionally, consider to use a LIMIT clause to avoid “Resources Exceeded” or “Response too large” fails.

like image 37
Rubens Mussi Cury Avatar answered Oct 15 '22 07:10

Rubens Mussi Cury