【发布时间】:2012-01-25 12:06:31
【问题描述】:
<?php
$c = pg_connect( $connectionString, PGSQL_CONNECT_FORCE_NEW );
$queries = array (
"SELECT COUNT(*) AS data FROM articles",
"SELECT * FROM posts WHERE visible = TRUE",
"SELECT * FROM countries WHERE visible = FALSE",
"SELECT * FROM types WHERE visible = TRUE"
);
foreach ( $queries as $query ) {
$res = @pg_query( $c, $query );
if ( empty( $res ) ) {
echo "[ERR] " . pg_last_error( $c ) . "\n";
} else {
echo "[OK]\n";
}
}
上面代码的sn-p是第一次生成这个:
[OK]
[OK]
[OK]
[OK]
但这是第二次:
[OK]
[OK]
[ERR] server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
[ERR] server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
这意味着某些缓存查询会导致问题。我们试图改变查询的顺序,但没有帮助。只有像SELECT 1+8 这样可能没有缓存的简单查询总是运行良好。
可以使用 psql 和任何其他语言驱动程序(不仅仅是 PHP)模拟类似的问题。
在我们安装PostgreSQL Query Cache的时候所有的麻烦都来了。
是否应该以某种方式配置查询缓存而不是这种方式?
我们的配置文件在这里: http://pastebin.com/g2dBjba0 – pcqd_hba.conf http://pastebin.com/X9Y3zrjx – pcqd.conf
【问题讨论】:
-
PostgreSQL或简称Postgres。没有“Postgre”。 More here. -
您是否尝试过使用 PDO pgsql 驱动程序?
-
正如我所说,即使使用原始的 psql(PostgreSQL 的 shell 工具),它的行为也是一样的。我使用哪个驱动程序并不重要。
标签: postgresql caching postgresql-9.0