Re: INSERT...SELECT pegs CPU, but is waiting on scattered read?

"Jesse, Rich" wrote:
> Here's an expanded excerpt:
> 
> =====================
> PARSING IN CURSOR #26 len=761 dep=1 uid=105 oct=2 lid=105 tim=951272192
> hv=1784939705 ad='e6f44c20'
> INSERT INTO part_usage_tmp
> SELECT
> ph.partno
> , DECODE(ph.warehouse,:"SYS_B_00",:"SYS_B_01",NULL,:"SYS_B_02",
> ph.warehouse) warehouse
> , ph.transqty
> FROM
> QT_PART_HISTORY_24_MONTHS ph,
> glxref gl
> WHERE
> ph.ACCOUNTNO = gl.ACCOUNTNO
> AND gl.ENTITY_CODE = :"SYS_B_03"
> AND ph.fiscal_year BETWEEN :"SYS_B_04" AND
> TO_NUMBER(TO_CHAR(TRUNC(SYSDATE), :"SYS_B_05"))
> AND TO_DATE(SUBSTR(TIME_STAMP,:"SYS_B_06",:"SYS_B_07"),:"SYS_B_08") BETWEEN
> :"SYS_B_09" AND LAST_DAY(ADD_MONTHS(TRUNC(SYSDATE),-:"SYS_B_10"))
> AND ph.transtype IN (:"SYS_B_11",:"SYS_B_12",:"SYS_B_13")
> AND gl.PRICELISTNO LIKE :"SYS_B_14"
> END OF STMT

Rich,

  if the condition on TIME_STAMP is a significant criterion, and if it
happens to be indexed, then the TO_DATE(SUBSTR(...) kills any hope of
seeing the index used. Write this condition otherwise (CURSOR_SHARING =
FORCE doesn't help, but I guess it is something to extract the month or
similar -  someting like TIME_STAMP between TRUNC(to_date(your value
here, suitable format), suitable truncation) and ...
In the worst case a function based index could provide some relief.

Otherwise I am not sure that in such a case, which I assume to be a
massive insert, the nested loop you have in your plan is what you need.
/*+ ALL_ROWS */ might help.

HTH,

Stephane Faroult
Oriole Software
----------------------------------------------------------------
Please see the official ORACLE-L FAQ: http://www.orafaq.com
----------------------------------------------------------------
To unsubscribe send email to:  oracle-l-request@xxxxxxxxxxxxx
put 'unsubscribe' in the subject line.
--
Archives are at http://www.freelists.org/archives/oracle-l/
FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html
-----------------------------------------------------------------

Other related posts: