SQL latency in the ADO Entity Framework

I need to create a file csvthat will contain all current subscribers, as well as a series of lines that come from the database.

to get all the subscribers that I follow:

public IQueryble<Subscribers> ListAllSubscribersByCalendarId(Decimal cid)
{
    return db.Subscribers.Where(x => x.calendar_id.Equals(cid));
}

pretty simple.

the problem is that I already have more than 5000 , and this one takes forever (literally)!

even showing only the last 30 entries takes a long time, my request is:

public IQueryble<Subscribers> ListLast30SubscribersByCalendarId(Decimal cid)
{
    return db.Subscribers
               .Where(x => x.calendar_id.Equals(cid))
               .Take(30)
               .OrderByDescending(x => x.created_date);
}

What can I do to speed up this process?

+3
source share
4 answers

. , : , .

0

SQL. , SQL, , , .

x.calendar_id == cid

+3

Aliostad . , calendar_id .

-, , 30, , 30, 30 ? 30 , created_date , .

, , , LINQ SQL- , .

+1

:

x.calendar_id:

sql:

public IQueryble<Subscribers> ListLast30SubscribersByCalendarId(Decimal cid)
{
    return db.Subscribers
               .Where(x => x.calendar_id.Equals(cid))
               .Take(30)
}

var ordered =  ListLast30SubscribersByCalendarId(1).ToList().OrderByDescending(x => x.created_date);
+1

Source: https://habr.com/ru/post/1776791/


All Articles