附件是一个小提琴,它在每个表旁边用注释来布置我的模式,以指示上述每个表中的行数。查询看起来像这样,以防小提琴被阻塞:
select distinct cat_name,cat_age, co_cat_owners_id,cat_weight,cs_is_alive,os_is_current, cos_is_current,
sum(cat_age) over(partition by co_cat_owners_id) running_total
from
(
select co.cat_owners_id co_cat_owners_id,
co.cat_id co_cat_id,
co.owner_id co_owner_id,
co.vet_id co_vet_id,
cos.is_current cos_is_current,
os.is_current os_is_current,
cs.is_alive cs_is_alive,
cat.name cat_name,
cat.age cat_age,
cat.weight cat_weight
from cat_owners co,
cat_owner_statuses cos,
cat_statuses cs,
cats cat,
owners o,
owner_statuses os
where o.owner_id = co.owner_id
and cat.cat_id = co.cat_id
and cos.last_visit >= sysdate - 4/24
)
where cs_is_alive = '1'
and (cos_is_current = '1' OR os_is_current='1')
group by cat_name,cat_age,cat_weight,cs_is_alive,os_is_current,co_cat_owners_id,cos_is_current;
在我的开发环境中,解释计划在步骤方面与小提琴内部的内容非常接近,但是我确实有几个步骤,其中内存大小为 15E(EB),行数为 4000P(PB)。我的问题是,在创建索引/错误 SQL 的过程中,我是否设法生成了一个 15 EB 的解决方案来解决应该可以在更少的空间和时间内解决的问题。我注意到调整一些复合索引创建步骤会产生稍微不同的结果,但我仍然被 Exabyte 空间要求所阻止。
笔记
如果将来有人没有阅读所有评论,请结合正确的连接运行以下功能:
analyze table table_name_here compute statistics;