From oracle-l-bounce@freelists.org Wed Sep 28 08:48:09 2005 Return-Path: Received: from air891.startdedicated.com (root@localhost) by orafaq.com (8.12.10/8.12.10) with ESMTP id j8SDm96R025803 for ; Wed, 28 Sep 2005 08:48:09 -0500 X-ClientAddr: 206.53.239.180 Received: from turing.freelists.org (freelists-180.iquest.net [206.53.239.180]) by air891.startdedicated.com (8.12.10/8.12.10) with ESMTP id j8SDm46H025785 for ; Wed, 28 Sep 2005 08:48:04 -0500 Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id C48471ED536; Wed, 28 Sep 2005 08:47:58 -0500 (EST) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 02985-10; Wed, 28 Sep 2005 08:47:58 -0500 (EST) Received: from turing (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 419F11EF15D; Wed, 28 Sep 2005 08:47:58 -0500 (EST) Subject: RE: PL/SQL question Message-ID: From: manoj.gurnani@polaris.co.in Date: Wed, 28 Sep 2005 19:15:29 +0530 To: oracle-l@freelists.org Cc: MIME-Version: 1.0 X-imss-version: 2.029 X-imss-result: Passed X-imss-approveListMatch: *@polaris.co.in X-MIMETrack: Serialize by Router on psldns.polaris.co.in/Polaris(Release 6.5.4FP1|June19, 2005) at 09/28/2005 07:15:45 PM, Itemize by SMTP Server on Trend-Smtp/Orion/IN(Release 6.5.1|January 21, 2004) at 09/28/2005 07:23:23 PM, Serialize by Router on Trend-Smtp/Orion/IN(Release 6.5.1|January 21, 2004) at 09/28/2005 07:23:31 PM, Serialize complete at 09/28/2005 07:23:31 PM Content-Type: text/plain; charset=US-ASCII X-archive-position: 26020 X-ecartis-version: Ecartis v1.0.0 Sender: oracle-l-bounce@freelists.org Errors-To: oracle-l-bounce@freelists.org X-original-sender: manoj.gurnani@polaris.co.in Precedence: normal Reply-To: manoj.gurnani@polaris.co.in X-list: oracle-l X-Virus-Scanned: by amavisd-new-20030616-p9 (Debian) at avenirtech.net X-mailscan-MailScanner-Information: Please contact the ISP for more information X-mailscan-MailScanner: Found to be clean X-MailScanner-From: oracle-l-bounce@freelists.org X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on air891.startdedicated.com X-Spam-Status: No, hits=-4.7 required=5.0 tests=BAYES_00,NO_REAL_NAME autolearn=no version=2.63 Is it possible for all detail tables be updated without using a cursor. can u explain with example. "Kennedy, Jim" , tor.com> cc: Subject: RE: PL/SQL question 09/28/2005 07:02 PM I don't see why you are using execute immediate. I think you could do it all in one sql statement. To quote Mr. Kyte "Row by row is slow by slow". I think you have over complicated it. Jim -----Original Message----- From: oracle-l-bounce@freelists.org on behalf of manoj.gurnani@polaris.co.in Sent: Wed 9/28/2005 6:28 AM To: oracle-l@freelists.org Subject: Re: PL/SQL question Below is the code. the cursor has about 300000 recs. The details tables have large volume of data and some have about 30 recs for each ref_num in cursor. This script has to be run .Can performance be increased. I've tested this for 3000 recs in cursor and with lesser volume of data in detail table. time taken is 25 min. Note :index is not present in all detail tables on column used in filter. set timing on set serverout on size 1000000 declare l_commit_interval number := 5000; l_where_clause varchar2(2000); l_cnt number := 0; l_owner varchar2(25) := 'OWNER1'; l_index_cnt number := 4; type txn_rec_tab_cnt is record ( tab_name varchar2(70), tab_aff_rows number(6):= 0 ); type t_tab_cnt is table of txn_rec_tab_cnt index by binary_integer; txn_tab_cnt t_tab_cnt; cursor c1 is select ref_num from trans where country_code = 'KK'; cursor c2 is select a.owner||'.'||a.table_name table_name,b.column_name from all_tab_columns a,all_tab_columns b where a.column_name = 'CTRY' and a.table_name = b.table_name and b.column_name in ('REF_NUM','BILL_REF_NUM','FLDR_T2_ID','TXN_REF_NUM') and a.owner = l_owner and b.owner = l_owner; begin for curs1 in c1 loop l_cnt := l_cnt + 1; l_index_cnt := 4; for curs2 in c2 loop l_where_clause := ' where '||curs2.column_name || ' = :col1'; execute immediate 'update '||curs2.table_name||' set ctry_cd = ''KK'''|| l_where_clause using curs1.ref_num; txn_tab_cnt(l_index_cnt).tab_name := curs2.table_name; txn_tab_cnt(l_index_cnt).tab_aff_rows:= txn_tab_cnt(l_index_cnt).tab_aff_rows+sql%rowcount; l_index_cnt := l_index_cnt + 1; end loop; if mod(l_cnt,l_commit_interval) = 0 then commit; end if; end loop; commit; for j in 1..txn_tab_cnt.count loop dbms_output.put_line('No of rows updated in '||txn_tab_cnt(j).tab_name||' = '||txn_tab_cnt(j).tab_aff_rows); end loop; end; / rjamya To: manoj.gurnani@polaris.co.in Sent by: cc: oracle-l@freelists.org oracle-l-bounce@fr Subject: Re: PL/SQL question eelists.org 09/28/2005 06:42 PM Please respond to rjamya You don't show us the code, you don't tell us what version,platform, you don't tell us how much time it takes and you don't tell us how much time ti should take. Sorry, the crystal ball is broken, come back in 3 weeks. ps: 1 lakh is one hundred thousand. Raj On 9/28/05, manoj.gurnani@polaris.co.in wrote: Hi, I've a cursor which retrieves about 3 lakh recs from a table.(master) based on column value retrieved from cursor for each rec,there are other tables (detail) to be updated. The detail tables have large volumes of data. the question is how can the performance be improved to achieve the desired result. This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately. You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited. Visit Us at http://www.polaris.co.in -- http://www.freelists.org/webpage/oracle-l This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately. You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited. Visit Us at http://www.polaris.co.in -- http://www.freelists.org/webpage/oracle-l