Preface
正好在做項(xiàng)目的時(shí)候碰到問(wèn)題辙谜,一個(gè)復(fù)雜的查詢語(yǔ)句
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
這條語(yǔ)句查詢?nèi)?lái)特別慢俺榆,在 PLSQL 客戶端查詢時(shí)間大概是5min,后來(lái)靈機(jī)一動(dòng)装哆,修改其中的LEFT JOIN 為 INNER JOIN肋演,瞬間變?yōu)?.1s查詢完畢......