インターネットまたはVPN経由でpostgresに接続すると、SQLサーバーよりも遅いのはなぜですか? テストがあります
DateTime now0 = System.DateTime.Now;
string sqlconnectsrting = "server=xxx.xxx.xxx.xxx;database=pubs;uid=sa;pwd=";
for (int i = 0; i < 1000; i++)
{
SqlConnection connect = new SqlConnection(sqlconnectsrting);
connect.Open();
connect.Close();
}
System.DateTime now1 = System.DateTime.Now;
Console.WriteLine(String.Format("SQL Connect time : {0}", now1 - now0));
now0 = System.DateTime.Now;
string npgconnectsrting = "Server=xxx.xxx.xxx.xxx;Port=5433;User Id=postgres;Password=postgres;Database=hr_data;";
for (int i = 0; i < 1000; i++)
{
NpgsqlConnection connect = new NpgsqlConnection(npgconnectsrting);
connect.Open();
connect.Close();
}
now1 = System.DateTime.Now;
Console.WriteLine(String.Format("Postgres Connect time : {0}", now1 - now0));
接続が localhost の場合は似ていますが、接続がインターネット経由の場合です。SQL 接続には 1 ~ 5 秒かかりますが、postgres には 3 ~ 7 分かかります。とにかくこれを修正する方法はありますか?
トゥアン ホアン アン