c# - Query seems to be really slow if there is no result set to return -


I am using linq for SQL in a web project. I LINQ got down SQL query and the subquery returns no other work well in any case the empty

  [T1] [Name] as [CategoryName], [t1]. As [CategoryID] [Store] from [CategoryID]. As [CategoryCountryCategoryTypeMappings] [t0] Join Insider [Store] [Categories] as [t1] on [t0]. [CategoryID] = [t1] [CategoryID] Where [[t1]. [StorefrontID] = 73) and (not present (selection as [empty] [dbo] as zero. [Download2] as [t2] ou ([t2]. [CategoryCountryCategoryTypeMappingID] = [t0]. [CategoryCountryCategoryTypeMappingID]) and (DatePart (h, [t2]. [DTS]) = 11) and (CONVERT (date, [t2]. [DTS]) = CONVERT (date, GETDATE ( )))))) Group by [T1]. [Name], [t1]. [Sreniaidi]  

Linux looks like this:

  Var notDLToUnion = (ntdl equal ntdl.CategoryID on ctdata.Category on cDataContext.Categories in Nhindaunlodedaidi there is cat.CategoryID where c at.StorefrontID == StorefrontID group new {cat.Name in t1, cat.CategoryID} by ntdl new CategoryStruct select {CategoryName = t1.Key.Name, status = 0, AverageResponseTime = 0, CategoryID = T1.Key.CategoryID});  

If I have not been downloaded, then what can I do to fix my Linux (or SQL) immediately?

This is another Avenue, I really do not need a group by Cat.name and cat.categoryId ... I just need a group by cat.Name, but I have access to cat.id Required, and there is a connection between the two.

Added comments: Some strange results were found in some quantities. It removes the group, makes it faster, removes a group by the key, makes it faster, does not exist by removing the subsystem (without or without empty set) it makes quicker

This type of rows have its intensity.

This is definitely not fast, and it is not too fast, if I add CategoryID after class from inside.

Edit: Adding downloadIds

  notDownloadedIds = cDataContext.CategoryCountryCategoryTypeMappings.Where (mapping = & gt;! CurrentLogs.Select (dll = & gt; dll.CategoryCountryCategoryTypeMappingID). Any (id = & gt; id = = mapping.CategoryCountryCategoryTypeMappingID));  

I delete this subquery and make it to join a left OUTER like this I am p>

  select [t1]. [Name] as [CategoryName], [t1]. [Store] from [CategoryID] as [Store]. Join [t0] Insider [Store] as [CategoryCountryCategoryTypeMappings]. [Categories] as [t1] on [t0]. [CategoryID] = [t1] [CategoryID] Join the Left External [dbo]. [T2] ​​[t2] running as [downloadLog]. [CategoryCountryCategoryTypeMappingID] = [t0]. [CategoryCountryCategoryTypeMappingID]) Where ([t1]. [StorefrontID] = 73) and [t2]. [CategoryCountryCategoryTypeMappingID] zero and (DatePart (h, [t2]. [DTS]) = 11) and (CONVERT (date, [t2]. [DTS]) = CONVERT (date, GETDATE ()) by [t1] Group [Name], [t1]. [CategoryID]  

It was made to top off my head and is untested, but I believe it will set you the same results pure Should be faster, faster.


Comments