pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-admin@lists.postgresql.org
Subject: Re: Disabling indexes on a table
Date: Thu, 18 Feb 2021 14:01:35 -0600
Message-ID: <9e9e980a-a11e-ad06-2c81-b6f0f7cd8b5f@gmail.com> (raw)
In-Reply-To: <8D9636C9-D38E-4857-A542-1469A11A25FF@gmail.com>
References: <8D9636C9-D38E-4857-A542-1469A11A25FF@gmail.com>

On 2/18/21 10:24 AM, John Scalia wrote:
> One of my developers asked me about this, and he suggested running the following update:
>
> UPDATE pg_index SET indisready=false
> WHERE indrelid = (select oid from pg_class where release = ‘his_table’);

He found that on the Internet:
https://fle.github.io/temporarily-disable-all-indexes-of-a-postgresql-table.html


> I told him it’s never a good idea to update anything in a system catalog by hand, but that I would reach out here for a better opinion. Am I correct that he shouldn’t try this, or is he OK to do this? His table has approximately 8 different indexes on it, and those really slow down his bulk loads. Usually when I have to get involved, I just drop his indexes and rebuild them afterwards, and I know that is always safe.

Disabling indices "just" saves having to run X number of CREATE INDEX 
statements, which is nothing to sneeze at since it's one less place to have 
to remember to update:  "REINDEX <table>;" just handles it all.

Just as importantly, the index you want to drop might be a PK supporting a FK.

(Postgresql really needs ALTER INDEX ... DISABLE and ALTER TABLE ... DISABLE 
ALL INDEXES;" statements.)

-- 
Angular momentum makes the world go 'round.





view thread (4+ messages)  latest in thread

Message-ID: <9e9e980a-a11e-ad06-2c81-b6f0f7cd8b5f@gmail.com>
Permalink:  ../9e9e980a-a11e-ad06-2c81-b6f0f7cd8b5f@gmail.com/
Also on:    postgresql.org/message-id/9e9e980a-a11e-ad06-2c81-b6f0f7cd8b5f@gmail.com

 · 

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: ronljohnsonjr@gmail.com, pgsql-admin@lists.postgresql.org
  Subject: Re: Disabling indexes on a table
  In-Reply-To: <9e9e980a-a11e-ad06-2c81-b6f0f7cd8b5f@gmail.com>

* 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