I recently struggled with the poor PHP documentation about how to set a connection timeout in the PHP PDO pgsql driver. After digging a bit in the PHP and libpq sources, I understood how it works under the hood and in this post I’m sharing my findings.