Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7927677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:26:47+00:00 2026-06-03T19:26:47+00:00

Ok so I am testing out EF once again for performance and I just

  • 0

Ok so I am testing out EF once again for performance and I just want a simple result back from my database.

Example

var jobsList = from j in mf.Jobs
                       where j.UserID == 1001 select new { Job = j };

This unfortunately joins my User object to this list, which I don’t want EF to do. How do I tell EF not to join just because there is a relationship. Basically I just want a simple row from that table.

Or do I need to use a different type of retrieval. I am still using the basic type of database retrieval below and I feel there are better ways to handle db work by now.

SqlConnection myconnection = new SqlConnection();

Edit

Basically what I am saying in a more clearer context. Is that instead of only getting the following.

Job.JobID
Job.UserID
//Extra properties

I Get

Job.JobID
Job.UserID
Job.User
//Extra properties

That User object easily consumes way more memory than is needed, plus I don’t need it.

My Solution

So I am still not believing in EF too much and here is why. I turned off LazyLoading and turned it on and didn’t really notice too much of a performance difference there. I then compared the amount of data that my SqlConnection type method uses compared to my EF method.

I get back the exact same result set and here are the performance differences.

For my Entity Framework method I get back a list of jobs.

MyDataEntities mf = new MyDataEntities(); // 4MB for the connection...really?
mf.ContextOptions.LazyLoadingEnabled = false;
// 9MB for the list below
var test = from j in mf.Jobs
           where j.UserID == 1031
           select j;
foreach (Job job in test) {
     Console.WriteLine(job.JobID);
}

For my SqlConnection method that executes a Stored Proc and returns a result set.

//356 KB for the connection and the EXACT same list.
List<MyCustomDataSource.Jobs> myJobs = MyCustomDataSource.Jobs.GetJobs(1031); 

I fully understand that Entity Framework is doing way way more than a standard SqlConnection, but why all this hype if it is going to take at a minimum of 25x more memory for a result set. Just doesn’t seem worth it.

My solution is not to go with EF after all.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T19:26:49+00:00Added an answer on June 3, 2026 at 7:26 pm

    The User property is part of the job class but wont be loaded until you access it (lazy loading). So it is not actually “joined”.

    If you only want the two specified columns you can write

    var jobsList = from j in mf.Jobs
                   where j.UserID == 1001 
                   select new { 
                              Job.JobID, 
                              Job.UserID 
                              };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm testing out the Google Places autocomplete feature here: https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete I want to get
I am testing out automatic deployment of build artifacts from Bamboo to Artifactory. I
I am testing out the simple pong game found here: https://github.com/shangaslammi/frp-pong The problem is
i'm just testing out the csv component in python, and i am having some
I am having issues testing out the Scala Parser Combinator functionality for a simple
We've just had some Penetration Testing carried out on an application we've built using
I just wrote an answer for someone else and when testing It turns out
I'm just testing out replacing a whole page with another page using JavaScript and
Testing out someone elses code, I noticed a few JSP pages printing funky non-ASCII
In testing out our API, one of our testers found out that when they

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.