title: How to speedup this query?
body: <p>Do you have some idea of how to speedup this query:</p>
  
  <pre><code>SELECT  Vosol = ( CASE WHEN EXISTS ( SELECT Id
                                       FROM   trs.CollectionHeaderView AS chv
                                       WHERE  chv.ItemNum = itm.ItemNum
                                              AND chv.CollectionType = '1' )
                         THEN ISNULL(itm.Amount, 0)
                         ELSE 0
                    END ) ,
          Vakhast = ( CASE WHEN EXISTS ( SELECT   Id
                                         FROM     trs.CollectionHeaderView AS chv
                                         WHERE    chv.ItemNum = itm.ItemNum
                                                  AND chv.CollectionType = '2' )
                           THEN ISNULL(itm.Amount, 0)
                           ELSE 0
                      END )
  FROM    trs.TrsDocRcvItem AS itm
          LEFT JOIN trs.TrsDocRcvHeader AS hdr ON itm.HeaderRef = hdr.Id
          LEFT JOIN acc.DL AS dl ON dl.Id = hdr.DLRef
          LEFT JOIN trs.TrsDocType AS docType ON docType.Id = hdr.DocTypeRef
          INNER JOIN sle.SleCustomer AS customer ON customer.DLRef = dl.Id
          LEFT JOIN trs.AccOperation AS operation ON operation.Id = itm.AccOperationRef
  WHERE   hdr.DocTypeRef NOT IN ( 1141, 1142, 1241, 1242 )
          AND ( hdr.State = '1'
                OR hdr.State = '2'
              )
          AND operation.StateType = '1'
  </code></pre>
  
  <p>I'm trying to optimize sql query which now takes about 6 second to execute.
  What more can I do to speedup this query? 
  I'm using Microsoft Sql Server.</p>