存在一個加速下面的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 –