From: Tom Lane <tgl@sss.pgh.pa.us>
To: Paul Green <traktion@webleicester.co.uk>
Cc: pgsql-admin@postgresql.org
Subject: Re: Broken index?
Date: Fri, 07 Sep 2001 10:53:16 -0400
Message-ID: <23506.999874396@sss.pgh.pa.us> (raw)
In-Reply-To: <20010907153917.A9567@trak.webleicester.co.uk>
References: <20010907100539.A7099@trak.webleicester.co.uk>
<22742.999871857@sss.pgh.pa.us>
<20010907153917.A9567@trak.webleicester.co.uk>
Paul Green <traktion@webleicester.co.uk> writes:
>> Hmm. What PG version is this, on what platform?
> Redhat 7.1, (Linux 2.4.2-2) on a K6-2 300 with 128 mb ram running PG 7.0
> What *is* wierd is that if I do, say, "select *
> from player where name='bob'" I get one result where as if I do a "select *
> from player where name like '%bob', I get many bobs (about 10) returned.
This is entirely consistent with the theory of a broken index. The %bob
query does a sequential scan and looks at every row, but the other will
do an index lookup and return only the rows it finds via the index.
Did you compile 7.0 with locale support? If so, a plausible theory is
that you've started the postmaster with different locale settings at
different times --- a change in locale would alter the effective sort
order, rendering what had been a valid index corrupt. The btree search
and update algorithms fail completely if the data in the index is not
really in the correct order.
Unfortunately it is *very* easy to start the postmaster with
inconsistent locale environment, since what you have in your login
profile is often different from the environment that system boot scripts
run in.
7.1 contains fixes that force PG always to use the initdb-time locale
setting, so as to eliminate this class of problems. I'd suggest an
upgrade. Meanwhile, you need to take steps to eliminate the duplicate
rows from your table.
> Also, if I do a "select count(id) from player" I get the
> same number as "select distinct count(id) from player" even though they
> should clearly be different.
Eh? Looks like the same thing to me. Perhaps you are thinking of
"select count(distinct id) from player"
> Also, I've just tried to do a query to update all rows by "update player
> set flatname=lower(name)" and that failed complaining about duplicates, yet
> if you specify the id, the row is altered. Crazy huh?
Once the index becomes corrupt, the behavior will be awfully
unpredictable...
regards, tom lane
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: tgl@sss.pgh.pa.us, traktion@webleicester.co.uk
Subject: Re: Broken index?
In-Reply-To: <23506.999874396@sss.pgh.pa.us>
References: <20010907100539.A7099@trak.webleicester.co.uk> <22742.999871857@sss.pgh.pa.us> <20010907153917.A9567@trak.webleicester.co.uk> <23506.999874396@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