执行较慢的待优化的SQL:
update business_new set fare1_balance_ratio = (select BALANCE_RATIO from bfare2 where bfare2.exchange_type = business_new.exchange_type and bfare2.stock_type = business_new.stock_type and (bfare2.entrust_way = business_new.entrust_way) and (bfare2.entrust_type = business_new.entrust_type) and bfare2.fare_type = '0')
从执行计划可以看出,走的就是nl关联,所以慢是正常的。
于是将其改写为merge,如下:
merge into business_new using bfare2 on (bfare2.exchange_type = business_new.exchange_type and bfare2.stock_type = business_new.stock_type and (bfare2.entrust_way = business_new.entrust_way) and (bfare2.entrust_type