我已经解决这个问题很长时间了,我决定我会在我的脑袋爆炸之前询问是否有人可以提出一些建议。
这是我正在运行的查询,它只是在子查询中多次重复相同的子子查询。我想看看我必须有哪些替代选项来加快速度。
到目前为止,我所能想到的只是运行一个初始查询,然后插入第二个查询的结果。
提前感谢任何人花时间看这个。
SELECT t2.* FROM TABLEA as t2 where
t2.link_id in
(
select t4.LinkA as link_list from TABLEB as t4
where t4.LinkB in (
select t1.id from TABLEC as t1 where t1.number in
(
(select t2.number from TABLEC as t2 where t2.id in
(
select t3.link_id from TABLEA as t3 where t3.an like "%20278%"
)
)
)
)
union
select t4.LinkB as link_list from TABLEB as t4
where t4.LinkB in (
select t1.id from TABLEC as t1 where t1.part_number in
(
(select t2.number from TABLEC as t2 where t2.id in
(
select t3.link_id from TABLEA as t3 where t3.an like "%20278%"
)
)
)
)
union
select t4.LinkA as link_list from TABLEB as t4
where t4.LinkA in (
select t1.id from TABLEC as t1 where t1.number in
(
(select t2.number from TABLEC as t2 where t2.id in
(
select t3.link_id from TABLEA as t3 where t3.an like "%20278%"
)
)
)
)
union
select t4.LinkB as link_idlist from TABLEB as t4
where t4.LinkA in (
select t1.id from TABLEC as t1 where t1.number in
(
(select t2.number from TABLEC as t2 where t2.id in
(
select t3.link_id from TABLEA as t3 where t3.an like "%20278%"
)
)
)
)
)