1

Say I have SQL Server installed on a server with an IP of 10.1.2.3. If I have a process running on that server that wishes to connect to the db it can use either:

  • 10.1.2.3,1433
  • localhost,1433
  • machinename,1433

The third option will incur slightly more overhead because it needs to lookup DNS each time correct? But what of the other two options? For all intents and purposes are they identical?

Obviously IPs can change, but localhost is always localhost so that is a benefit for that option, but on the other hand IP can be used from any machine within the network, localhost only on the server itself so that's a benefit for using IP. But I'm solely concerned with speed/performance/reliability/overhead, etc

1 Answer 1

2

For speed, your best bet is an IP, since it avoid a name lookup. There may be a reverse lookup on the server side of the connection, though. When using 'localhost', you are (likely) actually going to 127.0.0.1, not the external IP (or you should be, anyway, and if you're not something's not right). The advantage there is that you can change the external IP of the machine without having to change your connection string and things should still work.

Sign up to request clarification or add additional context in comments.

1 Comment

And what if process is running on a server different than DB? It would be great if you have a look here: stackoverflow.com/questions/24796532/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.