sql - Entity Framework performance vs Traditional ADO.Net -


to show question try explain sample:

suppose have table usersinfo these columns:

id, username, password, fname, lname, gender, birthday,  hometel, mobile, fax, email, lockstatus 

now want select lockstatus table. in traditional mode made query , send sqlcommand execute:

select lockstatus usersinfo 

and today use entity framework, use of query:

var q = r in new data_dbentities().usersinfo         select new         {            r.lockstatus         }; 

entity sql:

select usersinfo.lockstatus data_dbentities.usersinfo 

now start application , trace sql server profiler. if use first type of query (traditional mode) see result:

select lockstatus usersinfo 

but when use entity framework (linq || entity sql) sql server profiler show result:

select  [extent1].[lockstatus] [lockstatus] (select        [usersinfo].[id] [id],        [usersinfo].[username] [username],       [usersinfo].[password] [password],       [usersinfo].[fname] [fname],       [usersinfo].[lname] [lname],       [usersinfo].[gender] [gender],       [usersinfo].[birthday] [birthday],       [usersinfo].[hometel] [hometel],       [usersinfo].[mobile] [mobile],       [usersinfo].[fax] [fax],       [usersinfo].[email] [email],       [usersinfo].[lockstatus] [lockstatus]       [dbo].[usersinfo] [usersinfo]) [extent1] 

we can see ef in background select of columns.

now question is: want select 1 column, ef selects of columns. if had 100,000 records in table, performance bad!

maybe use function or stored procedure, when want select different columns in different tables, that's not idea.

what think? there way?

the query ef generated has redundant derived table in selects 1 column. sql server, , mainstream rdbms, physically touches single column in case. don't worry performance. cosmetics.

you have done nothing wrong. there's nothing you.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -