title: SQL Server 2005 query optimization
body: <p>My application need to get data from a SQL Server database. My problem is that there is 3 tables that has to be joined into a view. This takes a lot of time (about 30 sec to generate the view) So I was wondering if there is a way to optimize this SQL query?</p>
  
  <p>SQL query: </p>
  
  <pre><code>SELECT TOP (100) PERCENT Request1.RequestID,
                           TrackIT.dbo.Sending.Barcode,
                           TrackIT.dbo.Address_View.AdrID,
                           TrackIT.dbo.Address_View.Name,
                           TrackIT.dbo.Address_View.Street,
                           TrackIT.dbo.Address_View.HouseNo,
                           TrackIT.dbo.Address_View.Postal,
                           TrackIT.dbo.Address_View.City,
                           TrackIT.dbo.Address_View.Country,
                           Request1.Latitude,
                           Request1.Longitude,
                           Request1.ReceivedDate
  FROM   (SELECT DISTINCT RequestID,
                          Ltrim([Content]) AS Barcode,
                          Latitude,
                          Longitude,
                          ReceivedDate
          FROM   RequestWithLocation
          WHERE  ( Site LIKE '%Z' )
                 AND ( [Content] &lt;&gt; '' )
                 AND ( AddressID = '0' )
                 AND ReceivedDate &gt; Dateadd(day, -7, Getdate())) AS Request1
         INNER JOIN TrackIT.dbo.Sending
           ON Request1.Barcode = TrackIT.dbo.Sending.Barcode
         INNER JOIN TrackIT.dbo.Address_View
           ON TrackIT.dbo.Sending.DeliveryAdrID = TrackIT.dbo.Address_View.AdrID
  ORDER  BY AdrID 
  </code></pre>
  
  <p>Can anyone help ?</p>