title: Slow performing query, looking for ideas for solution
body: <p>I'm using SQL Server 2008. </p>
  
  <p>I have a view called testView</p>
  
  <p>In the view one of the columns is using another query taken from this page - <a href="http://www.simple-talk.com/sql/t-sql-programming/concatenating-row-values-in-transact-sql/" rel="nofollow">http://www.simple-talk.com/sql/t-sql-programming/concatenating-row-values-in-transact-sql/</a></p>
  
  <p>ie along this format</p>
  
  <pre><code>Create View testView as
      SELECT p1.CategoryId,    
             ( SELECT ProductName + ','    
                 FROM Northwind.dbo.Products p2    
                WHERE p2.CategoryId = p1.CategoryId    
                ORDER BY ProductName    
                  FOR XML PATH('') ) AS Products    
      FROM Northwind.dbo.Products p1
  </code></pre>
  
  <p>When the following query is run, it is taking about 110 seconds for when there are 60,000 rows in the view.</p>
  
  <pre><code>select * from testView where Products like '%asdf%'
  </code></pre>
  
  <p>What suggestions can be provided for improving this query?</p>