Performance issues using SQLClient
i use system.data.sqlclient in my aps.net core project,but why the first time i request it's very slow,after request it's faster.about few minutes later the request change slow again。
using (IDbConnection conn = DBFactory.GetDbConnection(serviceInfo.DBType))
{
conn.ConnectionString = serviceInfo.ConnectionString;
conn.Open();
IEnumerable<dynamic> ret = await conn.QueryAsync(serviceInfo.CommandText, _paramsValue);
var response = new { error_code = 0, error_desc = "", data = ret };
return JsonConvert.SerializeObject(response);
}
first request 4479ms second request 269ms
i use Dapper,but when i remove it,the test result is same.
i used Connection Pool
Server=xxxx;Database=xxxx;UID=xxx;PWD=xxxx;Max Pool Size=50;Min Pool Size=10;
Cc @geleems
thanks @saurabh500 @geleems @danmosemsft
@ICE2017 Which OS are you running the App on? What version of System.Data.SqlClient are you consuming? Can you give us a repro project as well?
thanks @saurabh500
windows server 2008 R2
System.Data.SqlClient, Version=4.2.0.0
the sql server version is 2008
the code is simple just like
using (IDbConnection conn = DBFactory.GetDbConnection(serviceInfo.DBType))
{
conn.ConnectionString = serviceInfo.ConnectionString;
conn.Open();
IEnumerable<dynamic> ret = await conn.QueryAsync(serviceInfo.CommandText, _paramsValue);
var response = new { error_code = 0, error_desc = "", data = ret };
return JsonConvert.SerializeObject(response);
}
Is the .Net code running on Windows or Linux?
on windows the version is winserver 2008 R2
I found some new things ,when i request the sqlserver,.NET Core Clinet will produce lot's pageiolatch_sh,
but i test .net framework 4.5 it's not.

@ICE2017 There was a problem with async query execution in SqlClient where the executions can happen in a sync manner. @geleems had submitted a fix at https://github.com/dotnet/corefx/pull/26595 Can you try out a nightly build from https://dotnet.myget.org/feed/dotnet-core/package/nuget/System.Data.SqlClient e.g. 4.5.0-preview2-26225-02 to see if this fixes your problem?
@saurabh500 thanks very much i will try
@ice2017 I also want to mention that based on the docs I read online that increase in pageiolatch on Sql could mean I/O issues on the server side. I don't know how strong is the correlation between increased pageiolatch and .Net core but you may want to look into it separately. .Net core uses pretty much the same code on windows to interact with Sql server as .Net framework does