Page 1 of 1
MySQL connection to IP is faster then a hostname?
Posted: Sun Dec 28, 2008 9:14 am
by kaisellgren
Hi,
Is it true that entering an IP instead of a hostname for MySQL is faster? Eg, entering 127.0.0.1 instead of localhost.
Re: MySQL connection to IP is faster then a hostname?
Posted: Sun Dec 28, 2008 9:34 am
by John Cartwright
I would assume so since the hostname needs to be translated into an IP eventually. However, I would assume the difference is a few microns.
Re: MySQL connection to IP is faster then a hostname?
Posted: Sun Dec 28, 2008 10:19 am
by kaisellgren
Jcart wrote:I would assume so since the hostname needs to be translated into an IP eventually. However, I would assume the difference is a few microns.
But it does exist. So it could be worth using the actual IP (if it's static).
Re: MySQL connection to IP is faster then a hostname?
Posted: Sun Dec 28, 2008 3:20 pm
by alex.barylski
The difference is minimal enough, doing so would be moot. It would be the same as not using whitespace in your source code, so that it tokenized faster.
The problem with using an IP is it's concrete and you do not own an IP address, so much as you do a domain. So while connecting using an IP is technically faster, it's a tradeoff you make for far more flexible, easy to follow source code.
Sometimes it is a delicate balance between ease of use, flexibility, etc over performance, but in this case, I would strongly encourage using a domain not an IP -- unless you have too.
This value is likely cached somewhere locally anyways, so I wouldn't worry to much about it.
Cheers,
Alex