我正在连接 7 个表并尝试创建一个临时表以进行进一步分析,但我的查询尚未完成。
然后,我从临时表创建另一个临时表,该表将在每列中保存不同的值:
create TEMPORARY TABLE all_data_counts as (
select date,
count(DISTINCT(gclid1)),
count(DISTINCT(gclid2)),
count(DISTINCT(gclid3)),
count(DISTINCT(gclid4)),
count(DISTINCT(gclid5)),
count(DISTINCT(gclid6)),
count(DISTINCT(gclid7)),
count(DISTINCT(gclid8))
from all_data group by date
);
select * from all_data_counts
如果我运行完整的代码,则查询在运行 20 分钟后仍未完成。
如果我只运行 left join
部分并选择将其显示,则需要 30 秒才能加入并显示它。
您知道为什么它不创建并显示具有 count(distinct)
值的临时表吗?
表格包含以下行:
我确实明白这个问题没有 MCRE,这是一个逻辑本身的问题,在尝试实现以下输出时是否有某种我不遵循的逻辑:
所有数据计数
Date gclid1 gclid2 gclid3 gclid4 gclid5 gclid6 gclid7 gclid8
2019-12-10 1000 900 800 700 600 500 400 300
感谢您的建议。
最佳答案
你的临时程序与直接运行整个程序相比如何......
select date,
count(DISTINCT(gclid1)) a,
count(DISTINCT(gclid2)) b,
count(DISTINCT(gclid3)) c,
count(DISTINCT(gclid4)) d,
count(DISTINCT(gclid5)) e,
count(DISTINCT(gclid6)) f,
count(DISTINCT(gclid7)) g,
count(DISTINCT(gclid8)) h
from
(
select g.date
, g.gclid gclid1
, k.click_id_from_request_url gclid2
, i.gclid gclid3
, s.Gclid gclid4
, d.Gclid gclid5
, ko.Gclid gclid6
, vo.gclid as gclid7
, v.gclid as gclid8
from full_google g
left
join full_cf_click k
on k.click_id_from_request_url = g.gclid
left
join full_cf_session_init i
on i.gclid = g.gclid
left
join full_session_start s
on s.Gclid = g.gclid
left
join full_clickout_database d
on d.Gclid = g.gclid
left
join full_clickout_has_offers ko
on ko.Gclid = g.gclid
left
join full_conversions_has_offers vo
on vo.gclid = g.gclid
left
join full_conversions_api v
on v.gclid = g.gclid
) x
group by date;
关于mysql - 创建临时表运行了 30 分钟但未完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59267173/