Reputation: 1493
Question
Is faster this
$servername = "125.125.55.10";
$username = "username";
$password = "password";
$conn = new mysqli($servername, $username, $password);
or this?
$servername = "mysql.server.com";
$username = "username";
$password = "password";
$conn = new mysqli($servername, $username, $password);
or it has no effect to speed?
I do not know if it has any practical use, but millisecond is milisecond....
Thank you
Upvotes: 3
Views: 1494
Reputation: 1272
The thing is, the first time your web-server will access mysql-database, it will cache resolved hostname. The problem with using IPs is that it's basically hardcode, it's hard to grep, IP can change far more frequently then hostname, etc. More than that: spending your time on premature optimizations like
is a waste of time, if your tables/scripts are not optimized.
what to look for in database (sql/nosql) performance:
Upvotes: 1
Reputation: 2915
Yes, it could be considered slightly faster, as there is no need to resolve the domain to an IP address (DNS lookup). However, most modern technologies will cache the IP address when a connection is made, meaning a DNS lookup does not have to be made for every connection to the same address. So the difference is neglible, apart from the first time you connect to a site, and even then only for a few seconds at most.
Upvotes: 4