Preface
正好在做项目的时候碰到问题,一个复杂的查询语句
SELECT count(*) FROM RSP_REBU_MAIN rrm
INNER JOIN RSP_STATE_APPLIED RSA
ON RRM.REBU_MAIN_ID = RSA.ENTITY_ID AND RSA.STATE_TYPE_CODE IN
( SELECT RST.STATE_TYPE_CODE FROM RSP_STATE_TYPE RST WHERE RST.PARENT_TYPE_ID =
( SELECT RST.STATE_TYPE_ID FROM RSP_STATE_TYPE RST WHERE RST.STATE_TYPE_CODE = 'RBS' ) )
INNER JOIN RSP_CUSTOMER RC ON RC.ID = rrm.CUSTOMER_ID
LEFT JOIN RSP_CUSTOMER_COMPANY_INFO rcci on rcci.id in
(select rac.ENTITY_ID from RSP_ASSOCIATION_CUSTOMER rac where RAC.ASSOCIATION_TYPE_CODE = 'CCCA' and rac.record_flag='0' and rrm.CUSTOMER_ID = CUSTOMER_ID)
WHERE RRM.RECORD_FLAG = 0 order by RRM.CREATED_TIME DESC
这条语句查询取来特别慢,在 PLSQL 客户端查询时间大概是5min,后来灵机一动,修改其中的LEFT JOIN 为 INNER JOIN,瞬间变为0.1s查询完毕......