Re: How can I find a broken row in a table

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Khangelani Gama <Khangelani(dot)Gama(at)ucs-software(dot)co(dot)za>
Cc: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: How can I find a broken row in a table
Date: 2010-04-16 14:23:48
Message-ID: 8600.1271427828@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Khangelani Gama <Khangelani(dot)Gama(at)ucs-software(dot)co(dot)za> writes:
> Please help me, I am using PostgreSQL 7.3.4 running on Redhat5

> there is a table that has a broken row, but now I don't know which one
is broken. the table has about 20974 pages. is there a command to find
this?

You have to use divide-and-conquer. Try

select ctid from table limit N;

and vary N until you find the largest value that *doesn't* produce an
error. The block number in the last ctid from that query is the block
before the bad one, or possibly a small number of blocks before the bad
one if there are some totally-empty blocks.

regards, tom lane

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Kevin Grittner 2010-04-16 14:26:45 Re: How can I find a broken row in a table
Previous Message Kevin Grittner 2010-04-16 14:14:00 Re: Vacuum Full (PG 8.1) - Urgent help needed - Cancel & transaction "liberation"