title: Why Sql type provider very slow?
body: <p>I have the following code. It will take a minutes if I change the line <code>where (row.SiteID = 1)</code> to <code>where (row.SiteID = 2)</code>. I searched on web and added <code>LocalSchemaFile = "Schema.dbml", ForceUpdate = false</code> for <code>SqlDataConnection</code>. It still takes about 15 seconds everytime when the query condition is changed.</p>
  
  <p><strong>Update:</strong><br>
  If I rerun the code without changing the Linq code, it will get and print the row from the database table instantly. </p>
  
  <pre><code>open System
  open System.Data
  open System.Data.Linq
  open Microsoft.FSharp.Data.TypeProviders
  open Microsoft.FSharp.Linq
  open System.Net
  open System.IO
  open FSharp.Data
  
  type dbSchema = SqlDataConnection&lt;"Data Source=Svr;Initial Catalog=DB;Integrated Security=SSPI;"&gt; 
  //, LocalSchemaFile = "Schema.dbml", ForceUpdate = false &gt; // Still take 15 secs
  let getARow =
      let db = dbSchema.GetDataContext()
      db.DataContext.Log &lt;- System.Console.Out
      let query = query { 
          for row in db.Table1 do 
          where (row.SiteID = 1) 
          select (Some(row.Col1, row.Col2))
          headOrDefault
          }
      query 
  
  [&lt;EntryPoint&gt;]
  let main argv = 
      let aRow = getARow
      printfn "%A" aRow 
      0
  </code></pre>