0

I have implemented a unitOfwork pattern that let me handle all the process of consulting the db, but I have been getting some perfomace issues. ex.

public Task<IEnumerable<BooksQueryResult>> GetBooks(int idBook, string Title, string Author)
{
   List<SqlParameter> sqlParams = new List<SqlParameter>();
        sqlParams.Add(new SqlParameter("idBook", queryParams.IdBook?? SqlString.Null));
        sqlParams.Add(new SqlParameter("Title", queryParams.Title?? SqlString.Null));
sqlParams.Add(new SqlParameter("Author", queryParams.Author?? SqlString.Null));


        return repos.DbSqlQueryAsync("EXEC usp_getValidBooks @IdBook, @Title, @Author, @DisclosurePeriod
                                               , sqlParams.ToArray());
}

It is supposed to return more than 20k records, but it takes almost 4 min.

Thanks

klashar
  • 2,519
  • 2
  • 28
  • 38
J. B
  • 202
  • 1
  • 9

1 Answers1

0

I believe this performance could be due to using Async method.

Async method can have performance issue when reading a large column from the server (such as varbinary(MAX), varchar(MAX), nvarchar(MAX) or XML).

You can find rducom answer which explains in detail the issue with async method here

Community
  • 1
  • 1
Jonathan Magnan
  • 10,874
  • 2
  • 38
  • 60