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 3843826
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:59:35+00:00 2026-05-19T15:59:35+00:00

I have a fairly large EF4 model, using POCO code gen. I’ve got lots

  • 0

I have a fairly large EF4 model, using POCO code gen. I’ve got lots of instances where I select a single entity from whichever table by its ID.

However on some tables, this takes 2 minutes or more, where on most tables it takes less than a second. I’m out of ideas as to where to look now, because I can’t see any reason. It’s always the same tables that cause problems, but I can query them directly against the database without problems, so it must be somewhere in Entity Framework territory that the problem is coming from.

The line is the quite innoccuous:

Dim newProd As New Product
Product.ShippingSize = Entities.ShippingSizes.Single(Function(ss) ss.Id = id)
  • id is simply an integer passed in from the UI, Id on my entity is the primary key, which is indexed on the database
  • Entities is a freshly created instance of my entity framework datacontext
  • This is not the first query being executed against the Context, it is the first query against this EntitySet though
  • I have re-indexed all tables having seen posts suggesting that a corrupt index could cause slow access, that hasn’t made any difference
  • The exact same line of code against other tables runs almost instantly, it’s only certain tables
  • This particular table is tiny – it only has 4 things in it

Any suggestions as to where to even start?

–edit – I’d oversimplified the code in the question to the point where the problem disappeared!

  • 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-05-19T15:59:36+00:00Added an answer on May 19, 2026 at 3:59 pm

    Where to start?

    1. Print or log the actual SQL string that’s being sent to the database.
    2. Execute that literal string on the server and measure its performance.
    3. Use your server’s EXPLAIN plan system to see what the server’s actually doing.
    4. Compare the raw SQL performance to your EF performance.

    That should tell you whether you have a database problem or an EF problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a fairly large PHP codebase (10k files) that I work with using
We're using EF4 in a fairly large system and occasionally run into problems due
I have a fairly large python 2.6 application with lots of print statements sprinkled
We have fairly large C++ application which is composed of about 60 projects in
I have a fairly large codebase that depends on MooTools v1.11 and am about
We have a fairly large SVN repository which we are looking to migrate to
I have a fairly large program written in C. It spans several files, and
I have a fairly simple ASP.NET 2.0 menu control using a sitemap file and
I have a fairly simple const struct in some C code that simply holds
I have fairly large C++ library with several sub-libraries that support it, and I

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.