title: How do I avoid timeouts with SqlServer full text search?
body: <p>We're using SqlServer 2008. In SSMS, queries on the full text catalog might take 2-5 seconds the first time, but after that, return quite quickly.</p>
  
  <p>On the other hand, running a query from via Linq2Sql will timeout.</p>
  
  <p>Here's what we have:</p>
  
  <p><strong>The SQL Inline Table UDF</strong></p>
  
  <pre><code>CREATE FUNCTION dbo.SearchArchiveFTS
  (   
      @query nvarchar(255)
  )
  RETURNS @ret TABLE 
  (
              ID      NVarChar(12) NOT NULL,
              snapshotDate    DateTime NOT NULL,
              -- about 10 more
  )
  AS BEGIN
      declare @innerQuery nvarchar(255)
      set @innerQuery = @query
      insert into @ret
      select      ID,
                  snapshotDate,
                  -- about 10 more
          from dbo.Archive a
          where contains(a.*, @innerQuery)
      return
  </code></pre>
  
  <p><strong>Query in SSMS</strong></p>
  
  <pre><code>select * from dbo.SearchArchiveFTS('query')
  //3 seconds / 3k rows
  </code></pre>
  
  <p><strong>Query in Linq2Sql</strong></p>
  
  <pre><code>db.SearchArchiveFTS("query").ToArray();
  // timeout exception
  </code></pre>
  
  <p>Any ideas on what the problem might be?</p>