Re: Index on System Table

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Cody Cutrer <cody(at)instructure(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Index on System Table
Date: 2012-03-21 18:17:42
Message-ID: 7802.1332353862@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Cody Cutrer <cody(at)instructure(dot)com> writes:
> On Tue, Mar 20, 2012 at 6:06 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> There's not really support for adding indexes to system catalogs
>> on-the-fly. I think it would work (barring concurrency issues)
>> for most catalogs, but pg_class has special limitations due to
>> the "relmapping" infrastructure. It's not something I'd particularly
>> care to try on a production database.

BTW, I experimented with that a little bit and found that the relmapper
is not really the stumbling block, at least not after applying this
one-line patch:
http://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=f70f095c9096d5e2689e8d79172b37b57a84e51b

It seemed to work for me to do this:

stop postmaster
start a standalone backend with -c allow_system_table_mods=1
create index pg_class_relnamespace_index on pg_class(relnamespace);
stop standalone backend, restart postmaster

There are a lot of gotchas here, notably that the session in which you
create the index won't know it's there (so in this case, a reindex on
pg_class would likely be advisable afterwards). I still think you'd be
nuts to try it on a production database, but ...

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Cody Cutrer 2012-03-21 18:32:46 Re: Index on System Table
Previous Message Lee Hachadoorian 2012-03-21 18:14:57 Re: huge price database question..