开发者

Why database connection caused to loads data very slow

开发者 https://www.devze.com 2023-03-24 20:45 出处:网络
This is my connection string : <add name=\"ConnectionString\" connectionString=\"Data Source=server;Initial Catalog=databaseName;Persist Security Info=True;User ID=username;Password=password\" pro

This is my connection string :

<add name="ConnectionString" connectionString="Data Source=server;Initial Catalog=databaseName;Persist Security Info=True;User ID=username;Password=password" providerName="System.Data.SqlClient" />

my web application runs fine when I run it from above ip address but it is so slow in other machine.

I mean it is slow but it works. I think there is a problem in type of connection string because another application using OleDb works very well. how I can fix it? I don't want change my applicatio开发者_Python百科n code.


There is nothing fundamentally wrong with that connection string. This leaves two likely scenarios:

  • the two machines have different network topology - maybe one is geographically distant, routing via a VPN tunnel on a slow link (making an absurdly exaggerated example for illustration only)
  • maybe the one application is sensibly written in terms of data access, and the other isn't

I imagine the second is the more likely scenario. If your application code doesn't filter at the appropriate places (i.e. loading an entire table to select a single row in memory), then yes: it will be poor.

I don't want change my application code.

If my guess above (the second bullet) is correct, then the poor performance is entirely the fault of application code, and the only fix would be to change the application code; "want" has very little to do with it. If you could show some of your example database access code that would obviously help, but rest assured: there is no inherent slowness caused by ADO.NET. However, poorly written data access application code will always result in bad performance.

If the issue is actually network topology, then you must design for that; applications designed for a fast local connection tend to perform badly when the DB and app are distant. The only fix there is, again, to change your application code to be less chatty - and hopefully less impacted by both latency (lots of small queries) and bandwidth (large queries) issues.


Were there changes made recently to your dns?

Try one of these two changes

  • Change the data source to an IP address:

    • command shell: ping (server name) -- this will give you the IP of the server
  • Change the server name to be fully qualified my including the domain name

    • instead of 'servername', set it to 'servername.mydomain.com'
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号