1。 问题分析描述
从阿里云日志 超时日志里捞出来的, 用到了SKU IN 子查询且元素比较多,查询比较蔓
2.解决方案
将SKU IN 改造有临时表或表值参数后join 这种方式查询,速度会快很多,之前改造过很多case.
优化前: select
select docId from tab1 where word in (select word from tab1 where docId=123) group by docId limit 1000;
优化后:
select docId from (select word from tab1 where docId=123) as t2 join tab1 t on t.word=t2.word
3.超时SQL
SELECT CustomerID,
SKU,
ClientSKU,
PackWeight,
GrossWeight,
LastSupplierPrice,
LastBuyPrice,
UnitShipFee,
IsRawMaterial,
LastBuyShipFee,
DeleteStatus
FROM RB_Product (nolock)
WHERE CustomerID = @CustomerID
AND SKU IN ( '4270566','4304464','4238624','4330153','4344246','4365989','4366050','4361479','4353294','4353356','4367342','4367539','4305854','4304527','4359313','4375552','4329370','4324693','4300280','4291153','4285796','4283513','4281534','4271222','4270363','4239797','4303225','4358115','4262070','4262110','4262122','4312899','4387059','4363965','4372656','4284353','4250811','4381014','4272640','4267928','4255819','4352406','4282373','4352262','4383722','4382682','4325342','4235236','4303334','4253728','4298056','4268500','4302645','4234486','4274424','4262280','4235205','4370190','4377021','4382813','4232495','4381342','4359011','4354365','4361389','4257499','4309328','4330024','4324052','4346621','4301901','4298591','4333849','4360702','4383658','4336595','4364599','4361987','4361864','4361594','4383009','4373457','4377597','4350068','4369399','4369333','4234494','4304375','4269940','4232695','4302046','4280459','4269765','4235430','4293853','4248381' )
PARAMS:@CustomerID = 1 ,
MESSAGE:执行超时已过期。完成操作之前已超时或服务器未响应。
