COBOL/DB2 cursor high CPU usage -
06-07-2011
, 10:47 AM
Hi,
In order to avoid duplicate records to be created, the program (COBOL)
requires user to check if the record they want to create already
exists in the database by searching on name (WSWA-SEARCH-STRING). The
following cursor is used. cust_id is a nine-digit field.
DECLARE CUST_CURSOR CURSOR FOR
SELECT
NAME,
CUST_ID
FROM CUST_TABLE
WHERE
SUBSTR(CUST_ID,1,3) IN ('000','888','999')
AND NAME LIKE :WSWA-SEARCH-STRING
Our DBA said the high CPU transactions occur when there are few (or
zero) records returned from the search. In that case DB2 looks
through the whole table for matches. That makes sense. But without
searching the whole table, how do you know if a record really does not
exist? I'm looking for ideas for reducing CPU usage.
Thanks much!
Bing |