[英]Postgresql slow simple queries using PHP PDO/driver
Having a hard time understanding why PostgreSQL from google cloud services is taking > 400 ms for any simple query (~4-row table) from my PHP code using PDO or pg driver.很难理解为什么来自谷歌云服务的 PostgreSQL 对于我的 PHP 代码使用 PDO 或 pg 驱动程序的任何简单查询(~4 行表)都需要超过 400 毫秒。 IP ping averages around 60 ms so it seems it's not a distance problem.
IP ping 平均在 60 毫秒左右,所以这似乎不是距离问题。 Using both PGAdmin and PHP yield around a 400+ ms response time.
同时使用 PGAdmin 和 PHP 产生大约 400+ 毫秒的响应时间。
$before_conn1 = microtime(true);
$result = pg_query($connector->conn(),$query);
$after_conn1 = microtime(true);
$test = $after_conn1 - $before_conn1;
echo $test;return;
// response time 0.46275 unix timestamp // 响应时间 0.46275 unix 时间戳
query looks like this:查询如下所示:
SELECT id,clearance from table
literally the table has 4 rows and 2 columns.从字面上看,该表有 4 行和 2 列。
Seems the lag was caused by the PDO driver.似乎滞后是由 PDO 驱动程序引起的。 I'm not sure exactly why but ended up using pg_query for a single query and pg_send_query for batch selects with the asynchronous response which worked really well.
我不确定为什么,但最终使用pg_query进行单个查询,使用pg_send_query进行批量选择,异步响应效果非常好。 Hope this helps others.
希望这对其他人有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.