3 ms·
Someone should benchmark that. Unix sockets in my mind should be faster as in theory you have less overhead. But the flow using TCP over loopback might have rec
by sgt 3y ago
Someone should benchmark that. Unix sockets in my mind should be faster as in theory you have less overhead. But the flow using TCP over loopback might have received many more optimizations over the last decades.
- mfalcao 3y agoHere's a quick benchmark with pgbench: $ pgbench -h localhost -p 5432 -b select-only -T 60 -c 10 -j 2 bench Password: pgbench (15.3 (Ubuntu 15.3-1.pgdg22.04+1)) starting vacuum...end. transaction type: <builtin: select only> scaling factor: 1 query mode: simple number of clients: 10 number of threads: 2 maximum number of tries: 1 duration: 60 s number of transactions actually processed: 10370147 number of failed transactions: 0 (0.000%) latency average = 0.058 ms initial connection time = 54.881 ms tps = 172993.008029 (without initial connection time) $ pgbench -h /var/run/postgresql -p 5432 -b select-only -T 60 -c 10 -j 2 bench pgbench (15.3 (Ubuntu 15.3-1.pgdg22.04+1)) starting vacuum...end. transaction type: <builtin: select only> scaling factor: 1 query mode: simple number of clients: 10 number of threads: 2 maximum number of tries: 1 duration: 60 s number of transactions actually processed: 16890415 number of failed transactions: 0 (0.000%) latency average = 0.036 ms initial connection time = 7.186 ms tps = 281540.260418 (without initial connection time) YMMV depending on your workload, but Unix sockets should always be significantly faster.
- sgt 3y agoVery interesting! Thank you for the effort.