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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:24:01+00:00 2026-05-28T20:24:01+00:00

I am developing an MVC website that uses the Entity Framework. I am an

  • 0

I am developing an MVC website that uses the Entity Framework. I am an ex ADO.Net forms man, so it’s all a bit new to me. My EDM currently consists of an abstract “Product” Entity, which has 5 different “type” Entities that inherit from it. The “Product” Entity maps to 7 or 8 tables and has about 50 properties, each “type” that inherits from a “Product” has some 5 to 20 extra properties that extend a “Product”. I notice that when I used the .Take extension method on the IQueryable to return data to a Telerik grid, it was taking noticably longer to return data than if I just greedily returned the whole collection to memory using .ToList.

When I ran SQL Profiler to see just what the devil was going on, here is what I found.

exec sp_executesql N'SELECT TOP (20)
[Project12].[C1] AS [C1], 
[Project12].[C2] AS [C2], 
[Project12].[C3] AS [C3], 
etc ... 508 SQL lines follow, too much to paste here unfortunately.

Takes 500 milliseconds to execute. The following however:

exec sp_executesql N'SELECT
[Project12].[C1] AS [C1], 
[Project12].[C2] AS [C2], 
[Project12].[C3] AS [C3], 
etc ... 

Takes around 80 milliseconds to execute.

So, judging by the above logic, I should ditch deferred execution, and every time the user changes page… take the entire dataset down into memory (500 rows or so). Does anyone have any suggestions what is going on and why SQL Server 2005 is behaving in this way?

EDIT

I’ve placed the full SQL on http://pastebin.com/rAGGSScA . Could it be that SQL is caching the “full” select, and not caching the “TOP (20)” results?

Client Statistics for SELECT

Select

Client Statistics for SELECT TOP (20)

Select Top

  • 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-28T20:24:02+00:00Added an answer on May 28, 2026 at 8:24 pm

    Somewhere in your “508 SQL lines [that] follow” will be an ORDER BY clause. By forcing a “TOP (N)” evaluation on the query, you are forcing the server to evaluate for this order by clause much earlier and compute all of the results (including their order) before any can be shown. You’ll likely end up with an entirely different execution plan, and may even void an index (or match of up with a less-desirable index). Without a “TOP (n)” clause, the server can begin showing results as soon as it knows a record will be used.

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

Sidebar

Related Questions

Hello i am currently developing a ASP.NET MVC 3 application that uses the new
I am developing a website using ASP.Net MVC 1.0. Can i host that website
I am developing a website using Asp.Net MVC framework. We need to add general
I'm developing a website with ASP.NET MVC, NHibernate and Fluent NHibernate and want to
I've been developing a simple website using asp.net MVC and I'm starting to add
I'm currently developing a website in ASP .NET MVC and I require functionality for
i have a problem i am developing an asp.net mvc project. Website is in
I am developing a website in Asp.net MVC. I pass the HttpContext to the
I'm developing an website using asp.net mvc with MySQL and I need to make
I am developing an ASP.NET MVC 2 web site, targeted for .NET Framework 4.0,

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.