我有一个查询(见下文)。当我把下面的行放在where子句中时,它运行得非常慢,当我把它放出来它运行得非常快时,无论如何我可以欺骗优化器,这将使我能够离开这是在where子句但是有相同的性能。我在Oracle 11g中运行。
AND uh.prod_exploitation_cre_surr_id IS NOT NULL
SELECT uh.prod_exploitation_cre_surr_id
, uh.rowid as uh_row_id
, uh.surr_id uh_surr_id
, uh.right_type
, uh.prod_received_with_cre_surr_id
, eap_bro.eap_broadcaster_name
, eap_bro.eap_broadcaster_station_id
, eap_bro.eap_production_number
FROM
(SELECT eap.eap_broadcaster_station_id, eap.eap_production_number, eap.eap_broadcaster_name, bro.tp_surr_id
FROM
(SELECT * from ETL_ACQUIRED_PRODUCTIONS where eap_date_added is null) eap
JOIN broadcasters bro ON eap.eap_broadcaster_station_id = bro.station_id) eap_bro
JOIN usage_headers uh ON uh.bro_broadcast_by_tp_surr_id = eap_bro.tp_surr_id
WHERE eap_bro.eap_production_number = uh.production_number
AND NVL (uh.dn_uls_usage_status, '3') NOT IN ('9', '11')
AND uh.right_type IN ('B', 'M')
AND uh.prod_exploitation_cre_surr_id IS NOT NULL -- line that makes it run slow
AND NOT EXISTS (SELECT 1
FROM production_usage_components puc
WHERE puc.uh_surr_id = UH.SURR_ID
AND PUC.DISTRIBUTION_STATUS IS NOT NULL);
提前感谢。