PostgreSQL: Unix domain socket vs TCP/IP loopback
PostgreSQL will use TCP/IP loopback (if you specify
if you specify nothing, it will use Unix domain socket.
Unix domain socket are similar to system pipes i.e. they only send data without checksums or other meta information, contrary to TCP/IP sockets that use a three-way handshake; in other words data carried over Unix sockets doesn't have to through the TCP/IP layers; there is also fewer context switches.
Bruce Momjian (a PostgreSQL core developer) made a benchmark which measured query network performance and showing that Unix socket communication was 33% faster than using the TCP/IP stack.
My Tech Newsletter
Get emails from me about programming & web development. I usually send it once a month