Back story:
I have a NASTY query I'm working with.
It's a "straight" select and it's over 800 lines long.
Problem:
There are approx 50 left joins to a kev/value table by GUID
I had tried turning this on it's side with:
I'm not seeing much improvement, and as expected, my memory usage went through the roof.
I'm going to pull the code bits out into a temp table, and then join on them, but am looking for any suggestions.
Lodlaiden
A lack of experience doesn't prevent you from doing a good job.
I have a NASTY query I'm working with.
It's a "straight" select and it's over 800 lines long.
Problem:
There are approx 50 left joins to a kev/value table by GUID
Code:
SELECT col47.Value MySpecialColumn
...
left join dbo.myLookupTable col47 (NOLOCK) on
col47.[ID] = myBaseTable.ID
and col47.myGUID = 'AAAAAAAAAAAAAAAAAAAAAA'
...
I had tried turning this on it's side with:
Code:
SELECT
...
MAX(CASE WHEN cols.ID ='AAAAAAAAAAAAAAAAAAAAA'
THEN cols.Value ELSE '' END) MySpecialColumn
...
LEFT JOIN dbo.myLookupTable cols (NOLOCK) on
cols.[ID] = myBaseTable.ID
...
GROUP BY myBaseTable.ID
I'm not seeing much improvement, and as expected, my memory usage went through the roof.
I'm going to pull the code bits out into a temp table, and then join on them, but am looking for any suggestions.
Lodlaiden
A lack of experience doesn't prevent you from doing a good job.