postgresql – 错误:无法读取关系1663/16384/16564的块4707:成功

我在Glassfishserver上使用psql 8.1.18.我有这样的查询
select ip,round((select sum(t1.size) from table t1)) 
from table 
where date > '2011.07.29' 
and date < '2011.07.30' 
and ip = '255.255.255.255' 
group by ip;

当我运行此查询时,我收到此错误

ERROR:  Could not read block 4707 of relation 1663/16384/16564: Success

但是这个查询工作正常:

select ip,round(sum(size)/175) 
from table 
where date > '2011.07.29' 
and l_date < '2011.07.30' 
and ip = '255.255.255.255' 
group by ip;

我认为这可能是一个数据库错误,我需要从备份恢复表,也许.但首先我需要了解这些损坏的数据存在的位置.有谁知道如何找到1663/16384/16564关系?还是4707块?

编辑:
我试过这段代码

select relname,relfilenode from pg_class where  relname in ('1663','16384','16564');

但它返回:

relname | relfilenode 
---------+-------------
(0 rows)
它看起来像是一个不好的块或索引.

要查找坏数据,可以查询pg_class视图;

选择oid,来自pg_class的relname,其中oid = 1663或oid = 16564;

看看结果是什么!

如果结果是索引,只需重新创建损坏的索引;

如果结果是一个表,则表示该表的某些数据已损坏,
您可以通过传递那些损坏的数据或将参数“zero_damaged_pa​​ges”设置为on
从最近的备份集恢复表!

有关参数“zero_damaged_pa​​ges”的更多信息
http://www.postgresql.org/docs/9.0/static/runtime-config-developer.html

相关文章

项目需要,有个数据需要导入,拿到手一开始以为是mysql,结果...
本文小编为大家详细介绍“怎么查看PostgreSQL数据库中所有表...
错误现象问题原因这是在远程连接时pg_hba.conf文件没有配置正...
因本地资源有限,在公共测试环境搭建了PGsql环境,从数据库本...
wamp 环境 这个提示就是说你的版本低于10了。 先打印ph...
psycopg2.OperationalError: SSL SYSCALL error: EOF detect...