【发布时间】:2019-05-20 09:00:15
【问题描述】:
我有一个在 10.6 上运行的 PostgreSQL 服务器,带有一个 openSUSE 发行版的 Linux,我刚刚设置了 pgpool-II,以允许我缓存查询。它工作正常,但由于未知原因,有时我会收到此警告消息:
WARNING: memcache: adding table oid maps, failed to create directory:"/var/log/pgpool/oiddir". error:"No such file or directory"
我已经创建了目录,将所有者更改为运行 pgpool 服务器的用户,并允许同一用户对该目录进行读取、写入和执行。
当查询尚未缓存时出现此消息,并且它似乎没有任何影响,即查询按应有的方式缓存,如果我再次缓存,结果是直接从缓存中拉取。
但是我还有一个问题,不知道是不是和第一个有关:
当我编写大查询(使用 JOIN、子查询、大量条件等)时,pgpool-II 不会缓存它们的结果(或者缓存它但不使用它,我不知道),即使结果不是大(少于 500 行)。此外,在这种情况下,我没有收到“oid”警告消息。我尝试提高允许使用 pgpool-II 的共享内存的不同限制(请参阅documentation),但它没有像我预期的那样改变,因为当 pgpool-II 由于缺少可用共享内存而无法缓存查询时,它是应该返回这样的消息:
LOG: pid 13756: pool_add_temp_query_cache: data size exceeds memqcache_maxcache. current:4095 requested:111 memq_maxcache:4096
但就我而言,我没有收到任何消息。以下是这两种情况的示例。
第一个问题
- 简单查询,结果被缓存,“oid”错误:
SELECT *
FROM some_table
WARNING: memcache: adding table oid maps, failed to create directory:"/var/log/pgpool/oiddir". error:"No such file or directory"
-- Doing it a second time will just give me the cached result without any warning, as expected
第二个问题
- 复杂查询,结果未缓存(或已缓存但未使用),没有警告/错误消息:
SELECT A.geom, A.id, to_char(C.timestamp, 'DD/MM/YY') as date, C.timestamp::time as time, ROUND(C.value) as value
FROM segments A, lines B, ( SELECT DISTINCT ON (B.id) B.id, A.timestamp, ROUND(A.nb1+A.nb2+A.nb3) as value
FROM records A
CROSS JOIN LATERAL (SELECT *
FROM points B
WHERE A.id = B.id
AND A.direction = B.direction
ORDER BY A.position <-> B.geom
LIMIT 1) AS B
ORDER BY B.id, A.timestamp DESC) AS C
WHERE A.id = B.id
AND B.id = C.id
AND A.direction = B.direction
AND B.direction = C.direction
-- Doing it a second time will just directly request the PostgreSQL server again, instead of pulling the result from the cache, as it should if the result was cached.
【问题讨论】:
标签: postgresql caching warnings shared-memory pgpool