2

I have a ASP.NET MVC 4 application and I'm using EF. I have a table and a SQL view(the view displays rows from this table plus some unimportant data(~ 1000 records)) with ~ 400.000 records. When I display the data in EF it takes 25 seconds

    MVCAppEntities db = new MVCAppEntities();
    public ActionResult Index()
    {
        return View(db.vvItem.OrderBy(n => n.Code).Skip(20).Take(40).ToList());
    }

In SQL Server Management Studio this query takes 0-1 seconds

select  code, quantity, name, price
from (
    select *,
           row_number() over(order by code) as rn
    from vvItem       
 ) as T
where T.rn between 20 and 40

Q : Why is the EF query so slow ? should I make a SP to do the Skip and Take ?

Misi
  • 748
  • 5
  • 21
  • 46

1 Answers1

1

Is it running faster in subsequent calls? It might just be a first time issue. Have a look at this link.

http://www.dotnetspark.com/kb/3706-optimizing-performance.aspx

Bishnu Paudel
  • 2,083
  • 1
  • 21
  • 39