locked
Timeout RRS feed

  • Question

  •  

    I'm using Link to SQL to connect to the database, from a web application in vb.net. I've a query with joins that works fine locally, but when I publish the web site in an external web server (using the same SQL Server) the application fails with a timeout error. The query is defined inside a Class Library. Can anybody help me?
    Monday, September 8, 2008 2:14 PM

Answers

  • Ah, I see.

     

    What I would do is examine the datacontext log to see what SQL it is generating then paste that into SQL Query Analyser and switch on the query plan options to see what it is doing.

     

    It sounds to me like it is doing a table scan or other intensive operation and you need to add some indexes but that's really a question for the SQL experts.

     

    [)amien

    Monday, September 8, 2008 7:20 PM
  • You might want to write a small console app that executes the LINQ query to see if you get any different results.  If this works well, then there's probably something up with your web server.

     

     

    Wednesday, September 10, 2008 11:55 PM
  • This actually sounds like an SQL connectivity issue rather than something with LINQ to SQL specifically so you might have more luck in the forums focused on that.

    A few things I would try though is considering if anything else is running on the web server, how that is performing etc. and how the SQL Connection is configured.

    Also worth trying the WITH NOLOCK option to see if perhaps multiple accesses to the same tables by multiple visitors/threads is causing a concurrency issue.

    [)amien
    Thursday, September 11, 2008 1:31 AM

All replies

  • It sounds to me like the external web server does not have access to the SQL server.  Is the SQL server internal and behind a firewall by any chance?  If so, you will need to open TCP 1433 between the two machines and ensure the client is set to use TCP as the primary connection mechanism from the SQL Client Configuration tool.

    [)amien
    Monday, September 8, 2008 3:12 PM
  • It's not possible Damien, because the external web server and the SQL Server are the same. Besides, other queries run fine, just this query (with 7 tables involved in Joins) do a timeout, but locally it's run quickly (there's few records in tables)

     

    Monday, September 8, 2008 3:33 PM
  • You might want to download LINQPad and try running your query from that.  If it still takes a very long time, I would recommend removing the joins one by one to see if any particular table is causing the trouble.  Perhaps there's some bad defragmentation of indexes, or corruption, or something of the sort.

     

    Hope this helps.

     

    -Larry

     

     

    Monday, September 8, 2008 5:13 PM
  • Ah, I see.

     

    What I would do is examine the datacontext log to see what SQL it is generating then paste that into SQL Query Analyser and switch on the query plan options to see what it is doing.

     

    It sounds to me like it is doing a table scan or other intensive operation and you need to add some indexes but that's really a question for the SQL experts.

     

    [)amien

    Monday, September 8, 2008 7:20 PM
  • Larry, I use de LINQPad and the query run very fast (0.040) whith all tables, as well as when I run my web site locally. The database it's always in the same server, the only change is the position of the web site, when I run it locally the query excecute ok, but when I run the same version published in the external server (that it's the same as the SQL Server) the query fails...

     

    Tuesday, September 9, 2008 9:38 AM
  • You might want to write a small console app that executes the LINQ query to see if you get any different results.  If this works well, then there's probably something up with your web server.

     

     

    Wednesday, September 10, 2008 11:55 PM
  • This actually sounds like an SQL connectivity issue rather than something with LINQ to SQL specifically so you might have more luck in the forums focused on that.

    A few things I would try though is considering if anything else is running on the web server, how that is performing etc. and how the SQL Connection is configured.

    Also worth trying the WITH NOLOCK option to see if perhaps multiple accesses to the same tables by multiple visitors/threads is causing a concurrency issue.

    [)amien
    Thursday, September 11, 2008 1:31 AM