Re: When/if to Reindex

From: "Steven Flatt" <steven(dot)flatt(at)gmail(dot)com>
To: "Mark Kirkwood" <markir(at)paradise(dot)net(dot)nz>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Gregory Stark" <stark(at)enterprisedb(dot)com>, "Bill Moran" <wmoran(at)collaborativefusion(dot)com>, "Vivek Khera" <vivek(at)khera(dot)org>, "Pgsql performance" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: When/if to Reindex
Date: 2007-08-24 14:22:38
Message-ID: 357fa7590708240722m204d678eid02b7ce3470eba1a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On 8/24/07, Mark Kirkwood <markir(at)paradise(dot)net(dot)nz> wrote:
>
> Tom Lane wrote:
> >
> > The fly in the ointment is that after collecting the pg_index definition
> > of the index, plancat.c also wants to know how big it is --- it calls
> > RelationGetNumberOfBlocks. And that absolutely does look at the
> > physical storage, which means it absolutely is unsafe to do in parallel
> > with a REINDEX that will be dropping the old physical storage at some
> > point.
>
> A suggestion that seems a bit like a leap backwards in time - maybe just
> use the pg_class.relpages entry for the index size?

Just throwing this out there (looking from a higher level)...

Why do we even need to consider calling RelationGetNumberOfBlocks or looking
at the pg_class.relpages entry? My understanding of the expected behaviour
is that while a reindex is happening, all queries run against the parent
table are planned as though the index isn't there (i.e. it's unusable).
This may/will result in sub-optimal query plans, but the point is that
reindex never blocks readers. Not sure if from an implementation standpoint
it's easy to mark an index as "being reindexed" in which case the planner
should just skip it.

Steve

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2007-08-24 16:15:25 Re: When/if to Reindex
Previous Message Heikki Linnakangas 2007-08-24 10:38:26 Re: partitioned table and ORDER BY indexed_field DESC LIMIT 1