I have a problem and right now I am out of ideas.
I am doing some optimisation for a database application. There is a method (Method_A) called a couple hundred times that does this kind of query:
SELECT
A.a,
ISNULL(A.b, 'Nothing') As alias_b
ISNULL(B.a, 'N/A') as alias_c
FROM A
LEFT JOIN B on A.fk=B.fk AND B.a = 'SOME_KEY'
WHERE A.c = 'SOME_OTHER_KEY'
Resulting in one row looking like this:
[a ][alias_b][ alias_c ]
[ val_a ][ val_b ][val_c|'N/A']
What I want to do in order to optimize my code is to make a single request before Method_A, retreiving all the data and make Method_A filter client-side. (It is coded in .NET, I am replacing an OleDBConnection with a DataSet)
How could I acheive this kind of behavior? Because if I filter with a client-side condition, instead of getting 'N/A' in the case where the join returns nothing, I just get no row, and this is a problem since I still need val_a and val_b
Thank you for your help!