sql 优化
SELECT L_SUPPKEY, COUNT(*)
FROM LINEITEM
GROUP BY L_SUPPKEY
UNION
SELECT S_SUPPKEY, 0
FROM SUPPLIER
WHERE S_SUPPKEY NOT IN ( SELECT L_SUPPKEY
FROM LINEITEM );
这样一个sql,怎么样改才能减少他的physical and logical read
------解决方案--------------------
SQL code
select SUPPLIER.S_SUPPKEY,count(LINEITEM.L_SUPPKEY)
from SUPPLIER
left join LINEITEM on SUPPLIER.S_SUPPKEY=LINEITEM.L_SUPPKEY
group by SUPPLIER.S_SUPPKEY;--少了个