SQL Server uncorrelated subquery very slow

Posted by brianberns on Stack Overflow See other posts from Stack Overflow or by brianberns
Published on 2010-12-23T22:49:51Z Indexed on 2010/12/23 22:54 UTC
Read the original article Hit count: 233

I have a simple, uncorrelated subquery that performs very poorly on SQL Server. I'm not very experienced at reading execution plans, but it looks like the inner query is being executed once for every row in the outer query, even though the results are the same each time. What can I do to tell SQL Server to execute the inner query only once?

The query looks like this:

select *
from Record record0_ 
where record0_.RecordTypeFK='c2a0ffa5-d23b-11db-9ea3-000e7f30d6a2' 
and (
    record0_.EntityFK in (
        select record1_.EntityFK 
        from Record record1_
        join RecordTextValue textvalues2_ on record1_.PK=textvalues2_.RecordFK 
        and textvalues2_.FieldFK = '0d323c22-0ec2-11e0-a148-0018f3dde540' 
        and (textvalues2_.Value like 'O%' escape '~')
    )
)

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about Performance