fetch only first row from oracle - is it faster?
- by john
My main goal with this question is optimization and faster run time.
After doing lot of processing in the Stored Proc I finally return a count like below:
OPEN cv_1 FOR
SELECT COUNT(*) num_of_members
FROM HOUSEHOLD_MEMBER a,
HOUSEHOLD b
WHERE RTRIM(LTRIM(a.mbr_last_name)) LIKE v_MBR_LAST_NAME || '%'
AND a.number = '01'
AND a.code = v_CODE
AND a.ssn_head = v_SSN_HEAD
AND TO_CHAR( a.mbr_dob, 'MM/DD/YYYY') = v_DOB;
But in my code that is calling the SP does not need the actual count. It just cares that count is greater than 1.
Question:
How can I change this to return just 1 or 0. 1 when count is 0 and 0 when count 1.
Will it be faster to do this rather than returning the whole count?