Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Stored Procedure Performance Problem --- Please Help

RE: Stored Procedure Performance Problem --- Please Help

From: Koivu, Lisa <lisa.koivu_at_efairfield.com>
Date: Fri, 31 Aug 2001 06:51:18 -0700
Message-ID: <F001.0037F1D4.20010831065024@fatcity.com>

Where's your tkprof output? First step always is to trace.

-----Original Message-----

From:   Viral Amin [SMTP:Viral.Amin_at_originindia.com]
Sent:   Friday, August 31, 2001 10:00 AM
To:     Multiple recipients of list ORACLE-L
Subject:        Stored Procedure Performance Problem --- Please Help

Hi All,

Hardware : Dell server - 256MB RAM, 13GB Hard Disk, Single CPU Software : Oracle 8.1.7 (Non-parallel server option) OS : Windows NT 4.0 SP6

BackGround: Following is the table structure and record count

desc tblcounter_reading
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 ID                                        NOT NULL NUMBER   -- Primary Key
 IDSERVER                                  NOT NULL NUMBER  
 IDCOUNTER                                 NOT NULL NUMBER
 DTREADINGTIME                             NOT NULL DATE
 NUMREADINGVALUE                                    NUMBER(38,20)
 YSNTRANSFORMFLAG                                   VARCHAR2(1)
SQL> select count(*) from tblcounter_reading;

  COUNT(*)                                                                     

----------                                                                     

  13283499  

Indexes on table TBLREPORTCOUNTER_READING

  1. Index on (id) PRIMARY KEY
  2. Index on (id, dtreadingtime)

Problem Description:

Following is the procedure which reads the above table and insert rows in the another table . This procedure execution takes very long time -- like 2-3 min for inserting one row in the other table. We need ways to  optimize this in the best possible manner so that the executiuon time is reduced.

Total time of execution - NOT KNOWN, could be ridiculously high like 20hrs or so.

Please help...In a very desparate situation.

Procedure:

CREATE OR REPLACE PROCEDURE transform_prc IS
  CURSOR cur_main
  IS
  SELECT distinct idserver,
         to_char(dtreadingtime, 'DD-MON-YYYY HH24:MI') dttime
    FROM tblcounter_reading a
   WHERE ysntransformflag IS NULL
     AND to_char(a.dtreadingtime, 'DAY') NOT IN ('SUNDAY   ', 'SATURDAY ');

  CURSOR cur_trans_main(pi_idserver IN NUMBER, pi_dtreadingtime IN DATE) IS
  SELECT numreadingvalue, idcounter
    FROM tblcounter_reading
   WHERE idserver       = pi_idserver
     AND dtreadingtime  = pi_dtreadingtime
     FOR UPDATE OF ysntransformflag ;

  CURSOR cur_tblcounter
    IS
  SELECT   id, strrptcolname
    FROM   tblcounter
   WHERE   nvl(ysnrptflag, 'X') = 'Y';

  v_strrptcolname   TBLCOUNTER.STRRPTCOLNAME%TYPE;
  v_collist   LONG   := Null;  -- Variable to store column list generated form TBLCOUNTER_READING table
  v_valuelist LONG   := Null;  -- Variable to store value list  generated form TBLCOUNTER_READING table
  v_sql_stmt  LONG   := Null;  -- Variable to store Dynamic DML
  v_alter_sess_stmt  VARCHAR2(1000)   := 'ALTER SESSION SET NLS_DATE_FORMAT = ' || '''' || 'DD-MON-RRRR HH24:MI' || '''' ;

  v_rowcnt Number := 1;
  v_prev_srv TBLCOUNTER_READING.IDSERVER%TYPE;


  TYPE tblcounter_TabType  IS TABLE OF tblcounter%ROWTYPE INDEX BY BINARY_INTEGER;
  tblcnt tblcounter_TabType;


BEGIN

  END LOOP;
END transform_prc;

Regards

Viral Amin Received on Fri Aug 31 2001 - 08:51:18 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US