title: SQL Sub-Query performance issue
body: <p>I'm having performance issues with my SQL sub query.</p>
  
  <p>As a hard-coded query, it takes about 1 second to run:</p>
  
  <pre><code>SELECT   ColumnA
          ,ColumnB
          ,ColumnC
  FROM    [LinkedServer].[Database].[Schema].[View]
  WHERE   ColumnA IN 
      (
          'ABC',
          'DEF',
          'HIJ',
          'KLM'
      )
  </code></pre>
  
  <p>However, the following code takes over a minute to run:</p>
  
  <pre><code>SELECT   ColumnA
          ,ColumnB
          ,ColumnC
  FROM    [LinkedServer].[Database].[Schema].[View]
  WHERE   ColumnA IN 
      (
          SELECT ColumnA FROM #TempTable
      )
  </code></pre>
  
  <p>The temp table contains the same 4 rows as the hard-coded example. The view on the linked server contains approx. 700,000 rows (and, unfortunately, is outside of my control). The ColumnA data types are the same and both tables are indexed.</p>
  
  <p>Any ideas on how to improve the performance of this query?</p>
  
  <p>Many thanks.</p>