[AccessD] Examples In Best Coding VB.net

Stuart McLachlan stuart at lexacorp.com.pg
Sat Oct 22 02:38:35 CDT 2016


> LINQ resolves to optimized SQL language to give
> you great performance.  

ROTFLMAO!

Just had a website bring a shared server to its knees because of LINQ resolving to the 
following "optimised" SQL:

(Admittedly the developer is a bit of a clown who doesn't really understand realtional 
databases - He took a view from an in house server that was based on 6 related tables and 
dumped the output of that view as a flat table - hence the SQL is drawing data from a wide 
table containing 4.5million records named  [dbo].[vw_SearchElectorDetails]  )

You will note that it actually pulls the entire table as a recordset which is then used as the  
source of the  actual select.


SELECT       
[Extent1].[LName] AS [LName],       [Extent1].[FName] AS
[FName],       [Extent1].[Gender] AS [Gender],       [Extent1].[Address]
AS [Address],       [Extent1].[DOB] AS [DOB],       [Extent1].[ElectorPK]
AS [ElectorPK],       [Extent1].[LocationName] AS [LocationName],      
[Extent1].[WardName] AS [WardName],       [Extent1].[LLGName] AS
[LLGName],       [Extent1].[DistrictName] AS [DistrictName],      
[Extent1].[ProvinceName] AS [ProvinceName]      

FROM 
(SELECT     
[vw_SearchElectorDetails].[LName] AS [LName],     
[vw_SearchElectorDetails].[FName] AS [FName],     
[vw_SearchElectorDetails].[Gender] AS [Gender],     
[vw_SearchElectorDetails].[Address] AS [Address],     
[vw_SearchElectorDetails].[DOB] AS [DOB],     
[vw_SearchElectorDetails].[ElectorPK] AS [ElectorPK],     
[vw_SearchElectorDetails].[LocationName] AS [LocationName],     
[vw_SearchElectorDetails].[WardName] AS [WardName],     
[vw_SearchElectorDetails].[LLGName] AS [LLGName],      [vw_Search
 ElectorDetails].[DistrictName] AS [DistrictName],     
 [vw_SearchElectorDetails].[ProvinceName] AS [ProvinceName]   

  FROM
 [dbo].[vw_SearchElectorDetails] AS [vw_SearchElectorDetails]) 

AS  [Extent1]    
WHERE [Extent1].[LName] = @p__linq__0

-- 
Stuart

On 21 Oct 2016 at 15:46, Dan Waters wrote:

...
> I also made the choice to use LINQ as the data layer between my
> application and SQL server.  And this is really the way to go.  It
> gives you intellisense while you're writing code for CRUD operations
> and you'll get error indicators on-screen if you've done something
> wrong.  Also - buy a copy of LINQPad Pro - it's a great sandbox for
> writing LINQ queries.  LINQ resolves to optimized SQL language to give
> you great performance.  
> 



More information about the AccessD mailing list