locked
Data fetching from SQL table is slow using EF RRS feed

  • Question

  • User981266171 posted

    Hi,

    Currently I'm developing web api where I'm getting the data from sql table is very slow.I'm getting slow at the below call.

    _dbContext.Employees.ToList();

    In the above line it is taking too much time, for the table proper indexing is already applied the same line of code is working in the Asp.Net MVC application which is already in production, but the same line of code is taking too much time in newly writting webapi services.

    Regards

    Sylendra

    Wednesday, December 5, 2018 9:06 AM

All replies

  • User753101303 posted

    Hi,

    As it seems ok in a MVC app, are you sure this is really this line rather than the time taken to transmit back all employee data over http ? Have you tried to time just this line rather than the begin to end API call ?

    Wednesday, December 5, 2018 9:43 AM
  • User981266171 posted

    Hi thanks for your reply,

    Yes at that particular line only it is taking too much time. I tested by calling the Api end point by keeping break point seems exactly at that line it is taking too much time like 12 seconds to fetch the 2046 records

    Wednesday, December 5, 2018 9:55 AM
  • User1120430333 posted

    Hi thanks for your reply,

    Yes at that particular line only it is taking too much time. I tested by calling the Api end point by keeping break point seems exactly at that line it is taking too much time like 12 seconds to fetch the 2046 records

    Hi thanks for your reply,

    Yes at that particular line only it is taking too much time. I tested by calling the Api end point by keeping break point seems exactly at that line it is taking too much time like 12 seconds to fetch the 2046 records

    Well, do you need all the properties in each object or only a few properties out of each object, not bringing all of the data if all of the data is not needed form each object?

    Wednesday, December 5, 2018 10:03 AM
  • User753101303 posted

    Do you have data such as images ? The data size does matter as well beyond just the number of rows. Also this is the first run or it happens even after.

    I'm trying first to understand why it seems retrieving the same data the same way seems quicker in your MVC app (really ?). The web API site is on another server than the MVC app ? 

    More generally as pointed already a common practice is not to retrieve all but to return what is really needed.

    Wednesday, December 5, 2018 10:09 AM
  • User-271186128 posted

    Hi Sylendra,

    Please check this article, you could tell the Entity Framework to select only certain specific columns, or implement the paging function.

    Best regards,
    Dillion

    Thursday, December 6, 2018 2:54 AM