Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: Select is fast, insert is very very slow
What version of oracle?
I have seen this behaviour in Oracle 8.0 that during the insert the explain plan for the select stuff was different than for the plain select. Running explain plan however did not reveal this (Have you tried explain planning this?) but I send a trace file to support and they came back with the difference. putting in a hint solved the problem/bug.
Jack
-----Original Message-----
[mailto:Ranganath.Krishnaswamy_at_blr.hpsglobal.com]
Sent: donderdag 15 mei 2003 10:02
To: Multiple recipients of list ORACLE-L
Hi List,
The below insert statement is taking about 5 minutes to insert around 74,000 records. I have altered the temp_segment_sr_filter table to nologging, increased the number of freelists to 2 and there are no indexes on the temp_segment_sr_filter table. The select statement takes only 250 ms to execute where as while inserting into the temp_segment_sr_filter it takes 5 minutes:
INSERT /*+ append */ INTO TEMP_SEGMENT_SR_FILTER (FLIGHT_SCH_KEY, FLIGHT_SCH_TYPE, FLIGHT_NO,FLIGHT_SGT_KEY, ORG_STN_KEY, DEST_STN_KEY, SERVICE_CODE, AC_TYPE_KEY, POSITION_CODE)
SELECT TDFS.FLIGHT_SCH_KEY, TDFS.FLIGHT_SCH_TYPE, FSH.FLIGHT_NO, FSG.FLIGHT_SGT_KEY, FSG.ORG_STN_KEY, FSG.DEST_STN_KEY, TOS.SERVICE_CODE, FSG.AC_TYPE_KEY AS AC_TYPE_KEY, POS.POSITION_CODE FROM TEMP_DAY_FLIGHT_SCHEDULE TDFS, FLIGHT_SCHEDULE FSH, FLIGHT_SGT FSG, TEMP_OFP_SERVICE TOS, POSITION POS WHERE TDFS.FLIGHT_SCH_KEY = FSH.FLIGHT_SCH_KEY AND FSH.FLIGHT_SCH_KEY = FSG.FLIGHT_SCH_KEY AND TOS.SERVICE_CODE <> '*' AND POS.POSITION_CODE <> '*' AND TDFS.FLIGHT_SCH_TYPE = 'F' AND FSG.AC_TYPE_KEY <> 132 AND NOT EXISTS ( SELECT /*+ index(SR i2_station_restriction) no_expand */ 1 FROM STATION_RESTRICTION SR, STN_RSTCN_TO_FRM SRTF, STN_RESTRICTION_SPL_CODE SRSC WHERE SR.STN_RSTCN_KEY = SRTF.STN_RSTCN_KEY AND SR.STN_RSTCN_KEY = SRSC.STN_RSTCN_KEY (+) AND SRSC.STN_RSTCN_KEY IS NULL AND (SR.AC_TYPE_KEY = FSG.AC_TYPE_KEY OR SR.AC_TYPE_KEY = 517 ) AND ( ( POS.POSITION_CODE IN ('E', 'TE') AND ( ( SR.STN_KEY = FSG.ORG_STN_KEY AND ( (SRTF.STN_KEY = FSG.DEST_STN_KEY) OR (SRTF.STN_KEY = 0) OR (SRTF.STN_KEY IS NULL ANDSRTF.COUNTRY_KEY = (SELECT COUNTRY_KEY FROM STATION WHERE STN_KEY = FSG.DEST_STN_KEY)) )
AND SR.AIRLINE_KEY = (SELECT AIRLINE_KEY FROM AIRLINE WHERE AIRLINE_CODE = SUBSTR(FSH.FLIGHT_NO, 1, 2) ) ) OR ( SR.STN_KEY = 0 AND ( (SRTF.STN_KEY = FSG.DEST_STN_KEY) OR (SRTF.STN_KEY = 0) OR (SRTF.STN_KEY IS NULL ANDSRTF.COUNTRY_KEY = (SELECT COUNTRY_KEY FROM STATION WHERE STN_KEY = FSG.DEST_STN_KEY)) )
AND SR.AIRLINE_KEY IN (
) ) AND (SR.VALID_FROM <=TRUNC(to_date('14-May-03'))+FSG.DEP_DAY_CHG AND SR.VALID_TO >= TRUNC(to_date('14-May-03'))+FSG.DEP_DAY_CHG)
AND (SR.WEEKDAYS LIKE ('%' ||DECODE(TO_CHAR(TRUNC(to_date('14-May-03'))+FSG.DEP_DAY_CHG, 'D'), '1', '7', TO_NUMBER(TO_CHAR(TRUNC(to_date('14-May-03'))+FSG.DEP_DAY_CHG , 'D')) - 1 ) || '%'))
) OR ( POS.POSITION_CODE IN ('I', 'TI') AND ( ( SR.STN_KEY = FSG.DEST_STN_KEY AND ( (SRTF.STN_KEY =FSG.ORG_STN_KEY) OR (SRTF.STN_KEY = 0) OR (SRTF.STN_KEY IS NULL AND SRTF.COUNTRY_KEY = (SELECT COUNTRY_KEY FROM STATION WHERE STN_KEY = FSG.ORG_STN_KEY)) )
AND SR.AIRLINE_KEY = (SELECT AIRLINE_KEY FROM AIRLINE WHERE AIRLINE_CODE = SUBSTR(FSH.FLIGHT_NO, 1, 2) ) ) OR ( SR.STN_KEY = 0 AND ( (SRTF.STN_KEY =FSG.ORG_STN_KEY) OR (SRTF.STN_KEY = 0) OR (SRTF.STN_KEY IS NULL AND SRTF.COUNTRY_KEY = (SELECT COUNTRY_KEY FROM STATION WHERE STN_KEY = FSG.ORG_STN_KEY)) )
AND SR.AIRLINE_KEY IN
) ) AND (SR.VALID_FROM <=TRUNC(to_date('14-May-03')) + FSG.ARR_DAY_CHG AND SR.VALID_TO >= TRUNC(to_date('14-May-03')) + FSG.ARR_DAY_CHG )
AND (SR.WEEKDAYS LIKE ('%' ||DECODE(TO_CHAR(TRUNC(to_date('14-May-03'))+FSG.ARR_DAY_CHG, 'D'), '1', '7', TO_NUMBER(TO_CHAR(TRUNC(to_date('14-May-03'))+FSG.ARR_DAY_CHG, 'D')) - 1 ) || '%'))
) ) --AND (SR.WEEKDAYS LIKE '%3%') AND ( (SR.RESTRICTED_POSITION = '*' AND SR.SERVICE_KEY = 5 ) OR (SR.RESTRICTED_POSITION = POS.POSITION_CODE AND SR.SERVICE_KEY = 5 ) OR (SR.RESTRICTED_POSITION = '*' AND SR.SERVICE_KEY = TOS.SERVICE_KEY ) OR (SR.RESTRICTED_POSITION = POS.POSITION_CODE AND SR.SERVICE_KEY = TOS.SERVICE_KEY ) ) AND IS_ALLOWED = 'N' )
Can anybody help me in imporving the insert performance? Any help in this regard is very much appreciated.
Thanks and Regards,
Ranganath
WARNING: The information in this message is confidential and may be legally privileged. It is intended solely for the addressee. Access to this message by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, or distribution of the message, or any action or omission taken by you in reliance on it, is prohibited and may be unlawful. Please immediately contact the sender if you have received this message in error. Thank you.
-- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Krishnaswamy, Ranganath INET: Ranganath.Krishnaswamy_at_blr.hpsglobal.com Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-LReceived on Thu May 15 2003 - 04:11:45 CDT
(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Jack van Zanen INET: JACK_at_QUANTSYSTEMS.NL Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).