存在一个加速下面的sql查询的机会?SQL优化(group by和max)
select
max(xtrid) as xtrid
, jid
from jpltab jl
inner join rb_cust u
on jl.custid = u.custid
where jl.tpe = 'Y'
and jl.jid in (51, 52, 53, 54, 55)
and u.org = 'INVCE'
group by jid
order by xtrid desc;
感谢
添加索引.... –
您能否包含执行计划? – VDK
由于您的Where子句中的jl.jid具有连续的数字,请将其更改为“介于51和55之间”,而不是“IN(51,52,53,54,55)”。这应该会让你有更好的表现。看到这里... https://stackoverflow.com/questions/3308280/is-there-a-performance-difference-between-between-and-in-with-mysql-or-in-sql-in –