我正在使用 BigQuery Studio,我的简单查询花费的时间太长

问题描述 投票:0回答:1

我的查询很简单,但花了很长时间。我是 BigQuery Studio 的新手,但我怀疑我已导入 BigQuery 的电子表格。 这是查询:

WITH MaxStepsPerDay AS (
  SELECT 
    Date,
    MAX(Steps) AS Max_Steps
  FROM `soy-codex-441615-u9.Women_wellness.minutes_Steps_March_to_april`
  WHERE Id = 1503960366
  GROUP BY Date
)
SELECT 
  ms.Date,
  ms.Max_Steps,
  original.Time
FROM MaxStepsPerDay ms
JOIN `soy-codex-441615-u9.Women_wellness.minutes_Steps_March_to_april` original
  ON ms.Date = original.Date AND ms.Max_Steps = original.Steps
WHERE original.Id = 1503960366;

错误信息是这样的:

查询执行期间超出资源:电子表格 ID 的 Google 表格服务超载:1J2zfUFbAWPtouinGNXbFZ_lmDvIT3k_gwGRsllRbQS0

如果有人能帮助我,我会很高兴, 谢谢!

google-bigquery
1个回答
0
投票

在 BQ 临时表中提取数据,然后按如下方式应用联接。这将降低复杂性


BEGIN

CREATE TEMP TABLE MaxStepsPerDay AS (
    SELECT Date,
    MAX(Steps) AS Max_Steps
  FROM `soy-codex-441615-u9.Women_wellness.minutes_Steps_March_to_april`
  WHERE Id = 1503960366
  GROUP BY Date
);


CREATE TEMP TABLE minutes_Steps_March_to_april AS (
SELECT DATE, 
       Steps,
       Time,
       FROM `soy-codex-441615-u9.Women_wellness.minutes_Steps_March_to_april` 
       WHERE Id = 1503960366
);


SELECT 
  ms.Date,
  ms.Max_Steps,
  original.Time
FROM MaxStepsPerDay ms
JOIN minutes_Steps_March_to_april original
  ON ms.Date = original.Date AND ms.Max_Steps = original.Steps;

END;
© www.soinside.com 2019 - 2024. All rights reserved.