I have to run the following in production. the following does a cartesian produc bettwen the two tables with 4000 records selected form P2 and 700 from I. I do not have sequences defined currently, so I do need the "+ rownum"
This is taking almost 4 hrs to run in the devp area to insert 2.5million rows. (I already have 0.5+ records in the table.
INSERT INTO PERM
SELECT I.CNY#, (select NVL(max(record#),0)+1 from PERM where cny# = I.CNY#)+rownum RECORD#,
'T' STATUS, I.RECORD#, P2.ELEMENT, P2.PERMISSION
FROM PERM P2, USERINFO I WHERE P2.CNY#= 571 AND P2.USERREC = 1 AND I.CNY# != 571 AND I.ADMIN = '1';
Did you do an explain plan on this to see how your query executes?:
SELECT I.CNY#, (select NVL(max(record#),0)+1 from PERM where cny# = I.CNY#)+rownum RECORD#,
'T' STATUS, I.RECORD#, P2.ELEMENT, P2.PERMISSION
FROM PERM P2, USERINFO I WHERE P2.CNY#= 571 AND P2.USERREC = 1 AND I.CNY# != 571 AND I.ADMIN = '1';
Bookmarks