From oracle-l-bounce@freelists.org Wed Sep 28 08:55:47 2005 Return-Path: Received: from air891.startdedicated.com (root@localhost) by orafaq.com (8.12.10/8.12.10) with ESMTP id j8SDtlsV027232 for ; Wed, 28 Sep 2005 08:55:47 -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 j8SDtf6H027207 for ; Wed, 28 Sep 2005 08:55:41 -0500 Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 4CE401ED042; Wed, 28 Sep 2005 08:55:36 -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 04843-06; Wed, 28 Sep 2005 08:55:36 -0500 (EST) Received: from turing (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id BEA891EF334; Wed, 28 Sep 2005 08:55:35 -0500 (EST) X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by Ecartis Subject: RE: PL/SQL question Date: Wed, 28 Sep 2005 09:53:41 -0400 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: PL/SQL question thread-index: AcXEMMpHqr5b2KQOQO+7QzQJqFOhaQAAuqnQ From: "Mercadante, Thomas F (LABOR)" To: , X-OriginalArrivalTime: 28 Sep 2005 13:53:42.0361 (UTC) FILETIME=[09518C90:01C5C434] X-archive-position: 26022 X-ecartis-version: Ecartis v1.0.0 Sender: oracle-l-bounce@freelists.org Errors-To: oracle-l-bounce@freelists.org X-original-sender: Thomas.Mercadante@labor.state.ny.us Precedence: normal Reply-To: Thomas.Mercadante@labor.state.ny.us 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=-3.5 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=2.63 Manoj, Are there indexes on the detail tables for the columns in the 'where' clauses for each table ('REF_NUM','BILL_REF_NUM','FLDR_T2_ID','TXN_REF_NUM')? Tom -----Original Message----- From: oracle-l-bounce@freelists.org [mailto:oracle-l-bounce@freelists.org] On Behalf Of manoj.gurnani@polaris.co.in Sent: Wednesday, September 28, 2005 9: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 -- http://www.freelists.org/webpage/oracle-l