So I was asked to change a query and optimize it as it was calling all columns of a table that was huge. I submitted this code:
It's a DB2 database.
The whole purpose of the query is to see if the associate is group qualified(TVCPMF). The code accepts 'G' for group or 'Y' for yes. If they are qualified, later on code allows them access to an area of our web portal that is otherwise locked.
TVAGTP is the associate number and the ? is the current users associate number.
TVCLIB.TVCAGTP is our associate table and houses all information about our associates, I think there are over a hundred columns at this point.
Once submitted the response from my supervisor was this:
I've wracked my brain and courted the help of one of our DBA's as well as two or three other programmers and I cannot for the life of me figure out how to make that code more efficient than it is.
Any ideas?
SELECT COUNT(TVCPMF) FROM TVCLIB.TVCAGTP WHERE TVAGTP = ? AND TVCPMF IN ('G', 'Y')
It's a DB2 database.
The whole purpose of the query is to see if the associate is group qualified(TVCPMF). The code accepts 'G' for group or 'Y' for yes. If they are qualified, later on code allows them access to an area of our web portal that is otherwise locked.
TVAGTP is the associate number and the ? is the current users associate number.
TVCLIB.TVCAGTP is our associate table and houses all information about our associates, I think there are over a hundred columns at this point.
Once submitted the response from my supervisor was this:
Quote
Code still uses less efficient technique
I've wracked my brain and courted the help of one of our DBA's as well as two or three other programmers and I cannot for the life of me figure out how to make that code more efficient than it is.
Any ideas?