script to drop and build all indexes in database

From: "Campbell, Lance" <lance(at)illinois(dot)edu>
To: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: script to drop and build all indexes in database
Date: 2013-12-13 21:55:30
Message-ID: B75CD08C73BD3543B97E4EF3964B7D701F65430B@CITESMBX1.ad.uillinois.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

PostgreSQL:9.2
OS: Linux
Does someone have a script that they would be willing to share that would:

1) Create a list of all indexes within database X

2) Loop for each index in list

3) Inside loop drop index then create index with concurrently

4) End loop

5) Exit script
I have been using the command, "REINDEX DATABASE somedatabename" , to rebuild all of my indexes on a production database used for web applications. But I believe while this is running late at night users are experiencing issues when they submit web requests that would write to tables that are being reindexed. I discovered that reindex does not allow for the use of concurrently as a parameter.

Suggestion:
It seems like it would be a good idea to add the parameter of concurrently to reindex.

Thanks so much,

Lance Campbell<http://illinois.edu/person/lance>
Software Architect
Web Services at Public Affairs
217-333-0382
[University of Illinois at Urbana-Champaign logo]<http://illinois.edu/>

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Kevin Grittner 2013-12-13 22:31:44 Re: AUTOVACUUM after purging a lot of records
Previous Message Jeni Fifrick 2013-12-13 21:51:20 Re: AUTOVACUUM after purging a lot of records