原sql运行正常外面包一层就很慢 (不相关子查询优化为相关子查询了?)

使用wtih table as 方式试试
with t as select sum(A.qty), D.name from
A
inner join B on xxx
inner join C on xxx
inner join D on xxx
group by D.name
select * from t where t.name = ‘name1’