在我的 Win 10 机器上连接到 postgresql 的时间慢得难以置信。连接需要 2.5-3.5 秒。
$ time 'c:/Program Files/PostgreSQL/10/bin/psql.exe' -h 127.0.0.1 -p 5433 -U xxx -c 'select true'
bool
------
t
(1 row)
real 0m3.416s
user 0m0.015s
sys 0m0.000s
Run Code Online (Sandbox Code Playgroud)
我尝试使用 psycopg2 python 驱动程序的同时。postgresql 版本 9 和 10 的时间相同。另一方面,连接到 mysql 的时间为 0.002,仅与 postgresql 相关。
这里有来自 postgresql 的 max debug 的相关日志
2018-03-19 21:24:43.654 +03 [10048] DEBUG: 00000: forked new backend, pid=21268 socket=5072
2018-03-19 21:24:43.654 +03 [10048] LOCATION: BackendStartup, postmaster.c:4099
2018-03-19 21:24:45.248 +03 [21268] LOG: 00000: connection received: host=127.0.0.1 port=9897 …Run Code Online (Sandbox Code Playgroud)