Query Failed Error: Resources exceeded during query execution: The query could not be executed in the allotted memory

Query Failed Error: Resources exceeded during query execution: The query could not be executed in the allotted memory

我使用的是标准 SQL.Even 虽然它是一个基本查询,但它仍然会抛出错误。有什么建议请

SELECT 
  fullVisitorId,
  CONCAT(CAST(fullVisitorId AS string),CAST(visitId AS string)) AS session,
  date,
  visitStartTime,
  hits.time,
  hits.page.pagepath
FROM
  `XXXXXXXXXX.ga_sessions_*`,
  UNNEST(hits) AS hits
WHERE
  _TABLE_SUFFIX BETWEEN "20160801"
  AND "20170331"
ORDER BY
  fullVisitorId,
  date,
  visitStartTime

此查询起作用的唯一方法是删除最后应用的排序:

SELECT 
  fullVisitorId,
  CONCAT(CAST(fullVisitorId AS string),CAST(visitId AS string)) AS session,
  date,
  visitStartTime,
  hits.time,
  hits.page.pagepath
FROM
  `XXXXXXXXXX.ga_sessions_*`,
  UNNEST(hits) AS hits
WHERE
  _TABLE_SUFFIX BETWEEN "20160801"
  AND "20170331"

ORDER BY 操作非常昂贵并且不能并行处理所以尽量避免它(或尝试在有限的结果集中应用它)

除了已接受的答案外,您可能还想按日期对 table 进行分区,以减少昂贵查询所使用的内存量。