我需要帮助来优化查询。并建议是否有任何其他方法可以通过使用任何其他查询来完成相同的任务。
WITH
q1 as
(select eid, data_used||'-'||status as value1
from T1 inner join T2 ON (t1.eid = t2.eid)
where <conditions>),
q2 as
(select eid, data_used||'-'||status as value2
from T1 inner join T2 ON (t1.eid = t2.eid)
where <conditions different from q1 >),
q3 as
(select eid, data_used||'-'||status as value3
from T1 inner join T2 ON (t1.eid = t2.eid)
where <conditions different from q2>)
select q1.eid, q1.value1, q2.value2, q3.value3
from q1, q2, q3
where q1.eid = q2.eid
and q2.eid=q3.eid;
查询将给出如下输出:
我的意思是说,根据 q1、q2 和 q3 中的条件,对于同一个 eid,value1、value 2、value 3 可以不同。
表 T1 和 T2 都是审计表,因此 eid 在两者中重复多次。
我真的厌倦了优化和缩短这个查询。我是新手。因此,我想知道是否有其他方法可以完成它。我在这些表上创建了索引,但它在 77 秒内返回数据。我需要将时间至少减少 10 - 15 秒。当前的数据量是 10 万条记录,并且将增长数十亿。