pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Khangelani Gama <Khangelani.Gama@ucs-software.co.za>
Cc: pgsql-admin@postgresql.org <pgsql-admin@postgresql.org>
Subject: Re: How can I find a broken row in a table
Date: Fri, 16 Apr 2010 10:23:48 -0400
Message-ID: <8600.1271427828@sss.pgh.pa.us> (raw)
In-Reply-To: <D78A8169F9436B4DB978300336168F3B3359AFE0FE@SWBREXCH00.ucs-software.net>
References: <D78A8169F9436B4DB978300336168F3B3359AFE0FE@SWBREXCH00.ucs-software.net>

Khangelani Gama <Khangelani.Gama@ucs-software.co.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



view thread (3+ messages)  latest in thread

Message-ID: <8600.1271427828@sss.pgh.pa.us>
Permalink:  ../8600.1271427828@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/8600.1271427828@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: tgl@sss.pgh.pa.us, Khangelani.Gama@ucs-software.co.za
  Subject: Re: How can I find a broken row in a table
  In-Reply-To: <8600.1271427828@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox