今天出個思考題,SQL比較簡單,有興趣的朋友可以一塊做一做:
這是個AWR顯示的TOP SQL(是以才有必要做優化):
select count(BC.SerialNo)
from Business_Duebill BC
where 1 = 1
and BC.operateuserid = :1
and BC.businessType like :2
and BC.businessType not like :3
and BC.businessType not like :4
and BC.businessType not like :5
and BC.businessType not like :6
and BC.PutoutDate > :7;
執行計劃及一組具體代表性的綁定變量:

表字段資料分布情況,紅色為sql使用到的幾個字段(SerialNO是主鍵),
提示:
目前使用的索引字段(operateuserid)選擇性一般;
putoutdate謂詞條件使用的變量日期也是比較久遠(目前是2016年了)
問題:
1、這個SQL在使用上有沒有什麼問題?具體在哪裡?
2、如果要優化這個SQL,你的方法是什麼?