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.
MySQL connection to IP is faster then a hostname?
Moderator: General Moderators
- kaisellgren
- DevNet Resident
- Posts: 1675
- Joined: Sat Jan 07, 2006 5:52 am
- Location: Lahti, Finland.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: MySQL connection to IP is faster then a hostname?
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.
- kaisellgren
- DevNet Resident
- Posts: 1675
- Joined: Sat Jan 07, 2006 5:52 am
- Location: Lahti, Finland.
Re: MySQL connection to IP is faster then a hostname?
But it does exist. So it could be worth using the actual IP (if it's static).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.
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: MySQL connection to IP is faster then a hostname?
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
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