bigquery resource limited exeeded due to order by

前端 未结 1 1472
南方客
南方客 2021-01-24 04:01

Whem I am running the following query, I get a \'resource limited exceeded\'-error. If I remove the last line (the order by clause) it works:

SELECT
  id,
  INTE         


        
相关标签:
1条回答
  • 2021-01-24 04:33

    A top-level ORDER BY will always serialize execution of your query: it will force all computation onto a single node for the purpose of sorting. That's the cause of the resources exceeded error.

    I'm not sure I fully understand your goal with the query, so it's hard to suggest alternatives, but you might consider putting an ORDER BY clause within the OVER(PARTITION BY ...) clause. Sorting a single partition can be done in parallel and may be closer to what you want.

    More general advice on ordering:

    • Order is not preserved during BQ queries, so if there's an ordering that you want to preserve on the input rows, make sure it's encoded in your data as an extra field.

    • The use cases for large amounts of globally-sorted data are somewhat limited. Often when users run into resource limitations with ORDER BY, we find that they're actually looking for something slightly different (locally ordered data, or "top N"), and that it's possible to get rid of the global ORDER BY completely.

    0 讨论(0)
提交回复
热议问题