Icon View Incident Report

Serious Serious
Reported By: Terry Swiers
Reported On: 12/11/2010
For: Version 2.04 Build 4
# 3359 Updates on Sensitive Result Set Cursors with ORDER BY Can Take Longer Than Necessary

I’ve got a performance issue with scripts and procedures that I think might be something that you want to look at. The script uses a sensitive cursor to pull back all of the records that need to be updated for a customer account running balance change. The reason that I’m sending you this is that it takes almost a minute for this script to update about 1250 records on my development system. This same function takes almost 4 minutes on my client’s system.

If I remove the update call in the script, it just screams through the data so it’s not a retrieval or navigation issue. Since it’s a sensitive cursor and I’m updating the current record, I would expect the updates to be much quicker since it’s already on the record that needs to be updated. I’ve removed all of the triggers from the AR table so I know it’s not another trigger causing the performance issues.

SCRIPT
BEGIN

DECLARE CustNum INTEGER DEFAULT 80;
DECLARE SequenceNumber INTEGER DEFAULT 57405;

DECLARE ARCursor SENSITIVE CURSOR FOR Stmt;

DECLARE lPrevBal FLOAT DEFAULT 0;
DECLARE lBalance FLOAT DEFAULT 0;
DECLARE lCurBal FLOAT DEFAULT 0;

PREPARE Stmt FROM 'SELECT custnum, prevbal, balance, curbal
  FROM ar where custnum = ? and SequenceNumber >= ? 
  order by SequenceNumber';

OPEN ARCursor USING CustNum, SequenceNumber;

--get the previous balance for the next record
FETCH FIRST FROM ARCursor ('CurBal') INTO lPrevBal;
--move to the next record
FETCH NEXT from ARCursor ('Balance') into lBalance;

WHILE NOT EOF(ARCursor) DO
  UPDATE ARCursor SET 'PrevBal' = lPrevBal,
      'CurBal' = Round(lPrevBal + lBalance, 2);
  SET lPrevBal = Round(lPrevBal + lBalance, 2);
  FETCH NEXT FROM ARCursor ('Balance', 'CurBal') INTO lBalance, lCurBal;
  END WHILE;
END



Resolution Resolution
Fixed Problem on 12/12/2010 in version 2.05 build 1


Products Affected Products Affected
ElevateDB Additional Software and Utilities
ElevateDB DAC Client-Server
ElevateDB DAC Client-Server with Source
ElevateDB DAC Standard
ElevateDB DAC Standard with Source
ElevateDB DAC Trial
ElevateDB LCL Standard with Source
ElevateDB PHP Standard
ElevateDB PHP Standard with Source
ElevateDB PHP Trial
ElevateDB VCL Client-Server
ElevateDB VCL Client-Server with Source
ElevateDB VCL Standard
ElevateDB VCL Standard with Source
ElevateDB VCL Trial

Image