Funpilot2

I am using VS2008 Beta 2 and Linq queries are taking a very long time to execute. I have a web project that creates a select statement from a Linq query as below...

SELECT [t0].[Division], [t0].[CaseNumber], [t0].[PartyName], [t0].[PartyType], [t0].[SummDate], [t1].[AttyName], [t3].[Description], [t2].[DateFiled] FROM [dbo].[Party] AS [t0] LEFT OUTER JOIN [dbo].[Atty] AS [t1] ON [t1].[AttyCode] = [t0].[Atty] LEFT OUTER JOIN [dbo].[Main] AS [t2] ON ([t2].[Division] = [t0].[Division]) AND ([t2].[CaseNumber] = [t0].[CaseNumber]) LEFT OUTER JOIN [dbo].[ActCode] AS [t3] ON ([t3].[Division] = [t2].[Division]) AND ([t3].[CodeKey] = [t2].[ActyCode]) WHERE [t0].[PartyName] LIKE @p0 ORDER BY [t0].[PartyName] -- @p0: Input String (Size = 5; Prec = 0; Scale = 0) [olen%] -- Context: SqlProvider(Sql2005) Model: AttributedMetaModel Build: 3.5.20706.1

As soon as the application Binds to the DataView, it takes about 40 seconds to display the web page (only 150 records are returned from this query).

If I enter the same select statement above in a Query using SQL Server Management Studio the result returns in 0.01 second.

I have no idea what is ahppening under the Linq hood, so I don't know where the slowdown is.

Any help or suggestions would be appreciated.



Re: LINQ Project General I can't understand why Linq is performing so slow.

Figo Fei - MSFT

Hi

What is your linq syntax and the tables schema look like

Thanks






Re: LINQ Project General I can't understand why Linq is performing so slow.

Funpilot2

Here is the code from a very simple query. It still takes a long time to return.

Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub _bSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles _bSearch.Click
Dim DB As New DataClassesDataContext
Dim Results = From P In DB.Parties Where P.PartyName Like _Name.Text.Trim & "*" _
Order By P.PartyName _
Select P.PartyName, P.Division, P.CaseNumber
GridView1.DataSource = Results
GridView1.DataBind()
End Sub

After checking the SQL Performance report it looks like the query did a table scan even though there is a proper index on the table. When I execute the exact select statement from Server Management Studio it uses the index.