Hey,
- Does using
localhost
inmysql_connect()
make the connection faster than using127.0.0.1
? - What is the connection type between the PHP script and mySQL (when using the
mysql_connect()
function) ? Is it TCP/IP?
Thanks
Joel
Hey,
localhost
in mysql_connect()
make the connection faster than using 127.0.0.1
?mysql_connect()
function) ? Is it TCP/IP?Thanks
Joel
1) Differs between Windows and Linux. If you use a unix domain socket it'll be slightly faster than using TCP/IP (because of the less overhead you have).
2) Windows is using TCP/IP as a default, whereas Linux tries to use a Unix Domain Socket if you choose localhost and TCP/IP if you take 127.0.0.1.
"localhost" means local socket connection while 127.0.0.1 is TCP/IP. And yes, sockets are faster than TCP/IP.
Cite from http://pl.php.net/mysql_connect
Whenever you specify "localhost" or "localhost:port" as server, the MySQL client library will override this and try to connect to a local socket (named pipe on Windows). If you want to use TCP/IP, use "127.0.0.1" instead of "localhost". If the MySQL client library tries to connect to the wrong local socket, you should set the correct path as in your PHP configuration and leave the server field blank.
Php site says:
Note:
Whenever you specify "localhost" or "localhost:port" as server, the MySQL client library will override this and try to connect to a local socket (named pipe on Windows). If you want to use TCP/IP, use "127.0.0.1" instead of "localhost". If the MySQL client library tries to connect to the wrong local socket, you should set the correct path as in your PHP configuration and leave the server field blank.
I guess the speed difference would be too low that it's something you should'nt be worried about.