pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
script to drop and create all indexes in a database with parameter concurrently
7+ messages / 4 participants
[nested] [flat]

* script to drop and create all indexes in a database with parameter concurrently
@ 2013-12-17 20:24  Campbell, Lance <lance@illinois.edu>
  0 siblings, 2 replies; 7+ messages in thread

From: Campbell, Lance @ 2013-12-17 20:24 UTC (permalink / raw)
  To: pgsql-admin

Below is a Linux script I wrote that will drop and create all of the indexes for your database with the "concurrently" parameter.

#!/bin/sh

dbhost=localhost
database=somedatabasename
dbschema=/tempfile/dbschema.txt
filtered=/tempfile/dbschema_filtered.txt
sql=/tempfile/rebuild_indexes.sql

rm "$dbschema"
rm "$filtered"
rm "$sql"

pg_dump -s -h "$dbhost" "$database" > "$dbschema"

grep -e CREATE\ INDEX -e SET\ search_path "$dbschema" | sed 's/CREATE\ INDEX/CREATE\ INDEX\ CONCURRENTLY/g' > "$filtered"

while read p; do

  if [[ "$p" == SET* ]]; then

    echo $p >> "$sql"

  else

    name=$(cut -d\  -f4 <<<"${p}")
    drop="DROP INDEX $name;"
    echo $drop >> "$sql"
    echo $p >> "$sql"

  fi

done < "$filtered"

psql -U ows -h "$dbhost" -d "$database" -f "$sql"

rm "$dbschema"
rm "$filtered"
rm "$sql"


Thanks,

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/;

Attachments:

image002.png (image/png, 5.9K) download view image
^ permalink raw reply [nested|flat] 7+ messages in thread

* Re: script to drop and create all indexes in a database with parameter concurrently
@ 2013-12-18 06:19  Doom.zhou <zzepaigh@gmail.com>
  parent: Campbell, Lance <lance@illinois.edu>
  1 sibling, 1 reply; 7+ messages in thread

From: Doom.zhou @ 2013-12-18 06:19 UTC (permalink / raw)
  To: Campbell, Lance <lance@illinois.edu>; +Cc: pgsql-admin

On Wed, Dec 18, 2013 at 4:24 AM, Campbell, Lance <lance@illinois.edu> wrote:

>  Below is a Linux script I wrote that will drop and create all of the
> indexes for your database with the “concurrently” parameter.
>
>
>
> #!/bin/sh
>
>
>
> dbhost=localhost
>
> database=somedatabasename
>
> dbschema=/tempfile/dbschema.txt
>
> filtered=/tempfile/dbschema_filtered.txt
>
> sql=/tempfile/rebuild_indexes.sql
>
>
>
> rm "$dbschema"
>
> rm "$filtered"
>
> rm "$sql"
>
>
>
> pg_dump -s -h "$dbhost" "$database" > "$dbschema"
>
>
>
 Great script !
i think you can add parallel perform each couple (drop & create index).  ^^

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: script to drop and create all indexes in a database with parameter concurrently
@ 2013-12-18 07:43  Doom.zhou <zzepaigh@gmail.com>
  parent: Doom.zhou <zzepaigh@gmail.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Doom.zhou @ 2013-12-18 07:43 UTC (permalink / raw)
  To: Campbell, Lance <lance@illinois.edu>; +Cc: pgsql-admin

oh my fault !!it's horrible
*ERROR:  deadlock detected*
*DETAIL:  Process 10504 waits for ShareUpdateExclusiveLock on relation
23298 of database 16407; blocked by process 10502.*
*        Process 10502 waits for ShareLock on virtual transaction 2/6981;
blocked by process 10504.*
*        Process 10504: CREATE INDEX CONCURRENTLY t_ems_log_opt_time_idx ON
t_ems_log USING btree (opt_time);*
*        Process 10502: CREATE INDEX CONCURRENTLY t_ems_log_create_by_idx
ON t_ems_log USING btree (create_by);*
*HINT:  See server log for query details.*
*STATEMENT:  CREATE INDEX CONCURRENTLY t_ems_log_opt_time_idx ON t_ems_log
USING btree (opt_time);*

*parallel feature script *


>>
>>
>>
>>
>>
> *#set variablesexport
> PATH=$HOME/bin:$PATH#main dbhost=192.168.0.214database=haierdbport=5432schema=publicdbschema=~/tbctemp/dbschema.txtfiltered=~/tbctemp/dbschema_filtered.txtsql=~/tbctemp/rebuild_indexes.sql rm
> "$dbschema"; rm "$filtered"; rm "$sql" pg_dump -U postgres -s -h "$dbhost"
> -p $dbport -n $schema  "$database" > "$dbschema" grep -e CREATE\ INDEX -e
> SET\ search_path "$dbschema" | sed 's/CREATE\ INDEX/CREATE\ INDEX\
> CONCURRENTLY/g' > "$filtered"#parallel tmp_fifofile="/tmp/$.fifo"mkfifo
> $tmp_fifofile      exec 6<>$tmp_fifofile     rm $tmp_fifofilethread=2for
> ((i=0;i<$thread;i++));do echodone >&6 # while read pdoread -u6   #if [[
> "$p" == SET* ]]; then  #  echo $p >> "$sql"  #else  {    name=$(cut -d\
>  -f4 <<<"${p}")    drop="DROP INDEX $name;"    echo $drop >> "$sql"    echo
> $p >> "$sql"        psql -U postgres -h "$dbhost" -p $dbport -d "$database"
> -c "$drop"        psql -U postgres -h "$dbhost" -p $dbport -d "$database"
> -c "$p"  #fi    echo >&6  } &done < "$filtered"waitexec 6>&-#psql -U
> postgres -h "$dbhost" -p $dbport -d "$database" -f "$sql" #rm
> "$dbschema"#rm "$filtered"#rm "$sql"  #end*




On Wed, Dec 18, 2013 at 2:19 PM, Doom.zhou <zzepaigh@gmail.com> wrote:

>
>
>
> On Wed, Dec 18, 2013 at 4:24 AM, Campbell, Lance <lance@illinois.edu>wrote:
>
>>  Below is a Linux script I wrote that will drop and create all of the
>> indexes for your database with the “concurrently” parameter.
>>
>>
>>
>> #!/bin/sh
>>
>>
>>
>> dbhost=localhost
>>
>> database=somedatabasename
>>
>> dbschema=/tempfile/dbschema.txt
>>
>> filtered=/tempfile/dbschema_filtered.txt
>>
>> sql=/tempfile/rebuild_indexes.sql
>>
>>
>>
>> rm "$dbschema"
>>
>> rm "$filtered"
>>
>> rm "$sql"
>>
>>
>>
>> pg_dump -s -h "$dbhost" "$database" > "$dbschema"
>>
>>
>>
>  Great script !
> i think you can add parallel perform each couple (drop & create index).  ^^
>

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: script to drop and create all indexes in a database with parameter concurrently
@ 2013-12-18 09:32  reiner peterke <zedaardv@gmail.com>
  parent: Campbell, Lance <lance@illinois.edu>
  1 sibling, 0 replies; 7+ messages in thread

From: reiner peterke @ 2013-12-18 09:32 UTC (permalink / raw)
  To: Campbell, Lance <lance@illinois.edu>; +Cc: pgsql-admin

i wanted to give a few thoughts regarding your script. 
I don't know your intended use, but generally indexes are not something that should be rebuilt over an entire database. I can not think of a scenario where I would need to do this. Building indexes takes system resources and should never be done blindly. 
If this is a production environment, dropping the indexes before rebuilding them would be horrible for system performance. A better approach would be to identify only those indexes that actually require a rebuild.
When rebuilding indexes, I create the new index first so there is always an index for queries needing them, then I drop and rename the index in a transaction as the last step. 

reiner

On 17 dec 2013, at 21:24, "Campbell, Lance" <lance@illinois.edu> wrote:

> Below is a Linux script I wrote that will drop and create all of the indexes for your database with the “concurrently” parameter.
>  
> #!/bin/sh
>  
> dbhost=localhost
> database=somedatabasename
> dbschema=/tempfile/dbschema.txt
> filtered=/tempfile/dbschema_filtered.txt
> sql=/tempfile/rebuild_indexes.sql
>  
> rm "$dbschema"
> rm "$filtered"
> rm "$sql"
>  
> pg_dump -s -h "$dbhost" "$database" > "$dbschema"
>  
> grep -e CREATE\ INDEX -e SET\ search_path "$dbschema" | sed 's/CREATE\ INDEX/CREATE\ INDEX\ CONCURRENTLY/g' > "$filtered"
>  
> while read p; do
>  
>   if [[ "$p" == SET* ]]; then
>  
>     echo $p >> "$sql"
>  
>   else
>  
>     name=$(cut -d\  -f4 <<<"${p}")
>     drop="DROP INDEX $name;"
>     echo $drop >> "$sql"
>     echo $p >> "$sql"
>  
>   fi
>  
> done < "$filtered"
>  
> psql -U ows -h "$dbhost" -d "$database" -f "$sql"
>  
> rm "$dbschema"
> rm "$filtered"
> rm "$sql"
>  
>  
> Thanks,
>  
> Lance Campbell
> Software Architect
> Web Services at Public Affairs
> 217-333-0382
> <image002.png>
>  
>  

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: script to drop and create all indexes in a database with parameter concurrently
@ 2013-12-18 15:04  Payal Singh <payal@omniti.com>
  parent: Doom.zhou <zzepaigh@gmail.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Payal Singh @ 2013-12-18 15:04 UTC (permalink / raw)
  To: Doom.zhou <zzepaigh@gmail.com>; +Cc: Campbell, Lance <lance@illinois.edu>; pgsql-admin

Why don't you simply use a bash script that:
1. gets list of all indexes in a file with prefix 'DROP INDEX...<index_name'
2. Since now each line is a command, input this file to psql.

On Wed, Dec 18, 2013 at 03:43:01PM +0800, Doom.zhou wrote:
> oh my fault !!it's horrible
> *ERROR:  deadlock detected*
> *DETAIL:  Process 10504 waits for ShareUpdateExclusiveLock on relation
> 23298 of database 16407; blocked by process 10502.*
> *        Process 10502 waits for ShareLock on virtual transaction 2/6981;
> blocked by process 10504.*
> *        Process 10504: CREATE INDEX CONCURRENTLY t_ems_log_opt_time_idx ON
> t_ems_log USING btree (opt_time);*
> *        Process 10502: CREATE INDEX CONCURRENTLY t_ems_log_create_by_idx
> ON t_ems_log USING btree (create_by);*
> *HINT:  See server log for query details.*
> *STATEMENT:  CREATE INDEX CONCURRENTLY t_ems_log_opt_time_idx ON t_ems_log
> USING btree (opt_time);*
> 
> *parallel feature script *
> 
> 
> >>
> >>
> >>
> >>
> >>
> > *#set variablesexport
> > PATH=$HOME/bin:$PATH#main dbhost=192.168.0.214database=haierdbport=5432schema=publicdbschema=~/tbctemp/dbschema.txtfiltered=~/tbctemp/dbschema_filtered.txtsql=~/tbctemp/rebuild_indexes.sql rm
> > "$dbschema"; rm "$filtered"; rm "$sql" pg_dump -U postgres -s -h "$dbhost"
> > -p $dbport -n $schema  "$database" > "$dbschema" grep -e CREATE\ INDEX -e
> > SET\ search_path "$dbschema" | sed 's/CREATE\ INDEX/CREATE\ INDEX\
> > CONCURRENTLY/g' > "$filtered"#parallel tmp_fifofile="/tmp/$.fifo"mkfifo
> > $tmp_fifofile      exec 6<>$tmp_fifofile     rm $tmp_fifofilethread=2for
> > ((i=0;i<$thread;i++));do echodone >&6 # while read pdoread -u6   #if [[
> > "$p" == SET* ]]; then  #  echo $p >> "$sql"  #else  {    name=$(cut -d\
> >  -f4 <<<"${p}")    drop="DROP INDEX $name;"    echo $drop >> "$sql"    echo
> > $p >> "$sql"        psql -U postgres -h "$dbhost" -p $dbport -d "$database"
> > -c "$drop"        psql -U postgres -h "$dbhost" -p $dbport -d "$database"
> > -c "$p"  #fi    echo >&6  } &done < "$filtered"waitexec 6>&-#psql -U
> > postgres -h "$dbhost" -p $dbport -d "$database" -f "$sql" #rm
> > "$dbschema"#rm "$filtered"#rm "$sql"  #end*
> 
> 
> 
> 
> On Wed, Dec 18, 2013 at 2:19 PM, Doom.zhou <zzepaigh@gmail.com> wrote:
> 
> >
> >
> >
> > On Wed, Dec 18, 2013 at 4:24 AM, Campbell, Lance <lance@illinois.edu>wrote:
> >
> >>  Below is a Linux script I wrote that will drop and create all of the
> >> indexes for your database with the “concurrently” parameter.
> >>
> >>
> >>
> >> #!/bin/sh
> >>
> >>
> >>
> >> dbhost=localhost
> >>
> >> database=somedatabasename
> >>
> >> dbschema=/tempfile/dbschema.txt
> >>
> >> filtered=/tempfile/dbschema_filtered.txt
> >>
> >> sql=/tempfile/rebuild_indexes.sql
> >>
> >>
> >>
> >> rm "$dbschema"
> >>
> >> rm "$filtered"
> >>
> >> rm "$sql"
> >>
> >>
> >>
> >> pg_dump -s -h "$dbhost" "$database" > "$dbschema"
> >>
> >>
> >>
> >  Great script !
> > i think you can add parallel perform each couple (drop & create index).  ^^
> >


-- 
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: script to drop and create all indexes in a database with parameter concurrently
@ 2013-12-18 20:02  Campbell, Lance <lance@illinois.edu>
  parent: Payal Singh <payal@omniti.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Campbell, Lance @ 2013-12-18 20:02 UTC (permalink / raw)
  To: Payal Singh <payal@omniti.com>; Doom.zhou <zzepaigh@gmail.com>; +Cc: pgsql-admin

Comment:
Why don't you simply use a bash script that:
1. gets list of all indexes in a file with prefix 'DROP INDEX...<index_name'
2. Since now each line is a command, input this file to psql.

I create all of my objects inside "schemas".  As a result that won't quite work because you need to set the search_path prior to doing the drop and create.  The script works for both those people that just use the public "schema" and those that use many "schema".  By "schema" I am referring to the name space that the database objects are built in.

Thanks,

Lance Campbell
Software Architect
Web Services at Public Affairs
217-333-0382 



-----Original Message-----
From: Payal Singh [mailto:payal@omniti.com] 
Sent: Wednesday, December 18, 2013 9:04 AM
To: Doom.zhou
Cc: Campbell, Lance; pgsql-admin@postgresql.org
Subject: Re: [ADMIN] script to drop and create all indexes in a database with parameter concurrently

Why don't you simply use a bash script that:
1. gets list of all indexes in a file with prefix 'DROP INDEX...<index_name'
2. Since now each line is a command, input this file to psql.

On Wed, Dec 18, 2013 at 03:43:01PM +0800, Doom.zhou wrote:
> oh my fault !!it's horrible
> *ERROR:  deadlock detected*
> *DETAIL:  Process 10504 waits for ShareUpdateExclusiveLock on relation
> 23298 of database 16407; blocked by process 10502.*
> *        Process 10502 waits for ShareLock on virtual transaction 2/6981;
> blocked by process 10504.*
> *        Process 10504: CREATE INDEX CONCURRENTLY t_ems_log_opt_time_idx ON
> t_ems_log USING btree (opt_time);*
> *        Process 10502: CREATE INDEX CONCURRENTLY t_ems_log_create_by_idx
> ON t_ems_log USING btree (create_by);*
> *HINT:  See server log for query details.*
> *STATEMENT:  CREATE INDEX CONCURRENTLY t_ems_log_opt_time_idx ON 
> t_ems_log USING btree (opt_time);*
> 
> *parallel feature script *
> 
> 
> >>
> >>
> >>
> >>
> >>
> > *#set variablesexport
> > PATH=$HOME/bin:$PATH#main 
> > dbhost=192.168.0.214database=haierdbport=5432schema=publicdbschema=~/tbctemp/dbschema.txtfiltered=~/tbctemp/dbschema_filtered.txtsql=~/tbctemp/rebuild_indexes.sql rm "$dbschema"; rm "$filtered"; rm "$sql" pg_dump -U postgres -s -h "$dbhost"
> > -p $dbport -n $schema  "$database" > "$dbschema" grep -e CREATE\ 
> > INDEX -e SET\ search_path "$dbschema" | sed 's/CREATE\ INDEX/CREATE\ 
> > INDEX\ CONCURRENTLY/g' > "$filtered"#parallel tmp_fifofile="/tmp/$.fifo"mkfifo
> > $tmp_fifofile      exec 6<>$tmp_fifofile     rm $tmp_fifofilethread=2for
> > ((i=0;i<$thread;i++));do echodone >&6 # while read pdoread -u6   #if [[
> > "$p" == SET* ]]; then  #  echo $p >> "$sql"  #else  {    name=$(cut -d\
> >  -f4 <<<"${p}")    drop="DROP INDEX $name;"    echo $drop >> "$sql"    echo
> > $p >> "$sql"        psql -U postgres -h "$dbhost" -p $dbport -d "$database"
> > -c "$drop"        psql -U postgres -h "$dbhost" -p $dbport -d "$database"
> > -c "$p"  #fi    echo >&6  } &done < "$filtered"waitexec 6>&-#psql -U
> > postgres -h "$dbhost" -p $dbport -d "$database" -f "$sql" #rm 
> > "$dbschema"#rm "$filtered"#rm "$sql"  #end*
> 
> 
> 
> 
> On Wed, Dec 18, 2013 at 2:19 PM, Doom.zhou <zzepaigh@gmail.com> wrote:
> 
> >
> >
> >
> > On Wed, Dec 18, 2013 at 4:24 AM, Campbell, Lance <lance@illinois.edu>wrote:
> >
> >>  Below is a Linux script I wrote that will drop and create all of 
> >> the indexes for your database with the “concurrently” parameter.
> >>
> >>
> >>
> >> #!/bin/sh
> >>
> >>
> >>
> >> dbhost=localhost
> >>
> >> database=somedatabasename
> >>
> >> dbschema=/tempfile/dbschema.txt
> >>
> >> filtered=/tempfile/dbschema_filtered.txt
> >>
> >> sql=/tempfile/rebuild_indexes.sql
> >>
> >>
> >>
> >> rm "$dbschema"
> >>
> >> rm "$filtered"
> >>
> >> rm "$sql"
> >>
> >>
> >>
> >> pg_dump -s -h "$dbhost" "$database" > "$dbschema"
> >>
> >>
> >>
> >  Great script !
> > i think you can add parallel perform each couple (drop & create 
> > index).  ^^
> >

-- 
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin


^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: script to drop and create all indexes in a database with parameter concurrently
@ 2013-12-19 00:30  Payal Singh <payal@omniti.com>
  parent: Campbell, Lance <lance@illinois.edu>
  0 siblings, 0 replies; 7+ messages in thread

From: Payal Singh @ 2013-12-19 00:30 UTC (permalink / raw)
  To: Campbell, Lance <lance@illinois.edu>; +Cc: Doom.zhou <zzepaigh@gmail.com>; pgsql-admin

not true. you can use something like --- select 'drop index
'||schemaname||'.'||indexname from pg_indexes;

It will return all <schema.index>

Payal Singh,
OmniTi Computer Consulting Inc.
Junior Database Architect,
Phone: 240.646.0770 x 253


On Wed, Dec 18, 2013 at 3:02 PM, Campbell, Lance <lance@illinois.edu> wrote:

> Comment:
> Why don't you simply use a bash script that:
> 1. gets list of all indexes in a file with prefix 'DROP
> INDEX...<index_name'
> 2. Since now each line is a command, input this file to psql.
>
> I create all of my objects inside "schemas".  As a result that won't quite
> work because you need to set the search_path prior to doing the drop and
> create.  The script works for both those people that just use the public
> "schema" and those that use many "schema".  By "schema" I am referring to
> the name space that the database objects are built in.
>
> Thanks,
>
> Lance Campbell
> Software Architect
> Web Services at Public Affairs
> 217-333-0382
>
>
>
> -----Original Message-----
> From: Payal Singh [mailto:payal@omniti.com]
> Sent: Wednesday, December 18, 2013 9:04 AM
> To: Doom.zhou
> Cc: Campbell, Lance; pgsql-admin@postgresql.org
> Subject: Re: [ADMIN] script to drop and create all indexes in a database
> with parameter concurrently
>
> Why don't you simply use a bash script that:
> 1. gets list of all indexes in a file with prefix 'DROP
> INDEX...<index_name'
> 2. Since now each line is a command, input this file to psql.
>
> On Wed, Dec 18, 2013 at 03:43:01PM +0800, Doom.zhou wrote:
> > oh my fault !!it's horrible
> > *ERROR:  deadlock detected*
> > *DETAIL:  Process 10504 waits for ShareUpdateExclusiveLock on relation
> > 23298 of database 16407; blocked by process 10502.*
> > *        Process 10502 waits for ShareLock on virtual transaction 2/6981;
> > blocked by process 10504.*
> > *        Process 10504: CREATE INDEX CONCURRENTLY t_ems_log_opt_time_idx
> ON
> > t_ems_log USING btree (opt_time);*
> > *        Process 10502: CREATE INDEX CONCURRENTLY t_ems_log_create_by_idx
> > ON t_ems_log USING btree (create_by);*
> > *HINT:  See server log for query details.*
> > *STATEMENT:  CREATE INDEX CONCURRENTLY t_ems_log_opt_time_idx ON
> > t_ems_log USING btree (opt_time);*
> >
> > *parallel feature script *
> >
> >
> > >>
> > >>
> > >>
> > >>
> > >>
> > > *#set variablesexport
> > > PATH=$HOME/bin:$PATH#main
> > >
> dbhost=192.168.0.214database=haierdbport=5432schema=publicdbschema=~/tbctemp/dbschema.txtfiltered=~/tbctemp/dbschema_filtered.txtsql=~/tbctemp/rebuild_indexes.sql
> rm "$dbschema"; rm "$filtered"; rm "$sql" pg_dump -U postgres -s -h
> "$dbhost"
> > > -p $dbport -n $schema  "$database" > "$dbschema" grep -e CREATE\
> > > INDEX -e SET\ search_path "$dbschema" | sed 's/CREATE\ INDEX/CREATE\
> > > INDEX\ CONCURRENTLY/g' > "$filtered"#parallel
> tmp_fifofile="/tmp/$.fifo"mkfifo
> > > $tmp_fifofile      exec 6<>$tmp_fifofile     rm
> $tmp_fifofilethread=2for
> > > ((i=0;i<$thread;i++));do echodone >&6 # while read pdoread -u6   #if [[
> > > "$p" == SET* ]]; then  #  echo $p >> "$sql"  #else  {    name=$(cut -d\
> > >  -f4 <<<"${p}")    drop="DROP INDEX $name;"    echo $drop >> "$sql"
>  echo
> > > $p >> "$sql"        psql -U postgres -h "$dbhost" -p $dbport -d
> "$database"
> > > -c "$drop"        psql -U postgres -h "$dbhost" -p $dbport -d
> "$database"
> > > -c "$p"  #fi    echo >&6  } &done < "$filtered"waitexec 6>&-#psql -U
> > > postgres -h "$dbhost" -p $dbport -d "$database" -f "$sql" #rm
> > > "$dbschema"#rm "$filtered"#rm "$sql"  #end*
> >
> >
> >
> >
> > On Wed, Dec 18, 2013 at 2:19 PM, Doom.zhou <zzepaigh@gmail.com> wrote:
> >
> > >
> > >
> > >
> > > On Wed, Dec 18, 2013 at 4:24 AM, Campbell, Lance <lance@illinois.edu
> >wrote:
> > >
> > >>  Below is a Linux script I wrote that will drop and create all of
> > >> the indexes for your database with the “concurrently” parameter.
> > >>
> > >>
> > >>
> > >> #!/bin/sh
> > >>
> > >>
> > >>
> > >> dbhost=localhost
> > >>
> > >> database=somedatabasename
> > >>
> > >> dbschema=/tempfile/dbschema.txt
> > >>
> > >> filtered=/tempfile/dbschema_filtered.txt
> > >>
> > >> sql=/tempfile/rebuild_indexes.sql
> > >>
> > >>
> > >>
> > >> rm "$dbschema"
> > >>
> > >> rm "$filtered"
> > >>
> > >> rm "$sql"
> > >>
> > >>
> > >>
> > >> pg_dump -s -h "$dbhost" "$database" > "$dbschema"
> > >>
> > >>
> > >>
> > >  Great script !
> > > i think you can add parallel perform each couple (drop & create
> > > index).  ^^
> > >
>

^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2013-12-19 00:30 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-12-17 20:24 script to drop and create all indexes in a database with parameter concurrently Campbell, Lance <lance@illinois.edu>
2013-12-18 06:19 ` Doom.zhou <zzepaigh@gmail.com>
2013-12-18 07:43   ` Doom.zhou <zzepaigh@gmail.com>
2013-12-18 15:04     ` Payal Singh <payal@omniti.com>
2013-12-18 20:02       ` Campbell, Lance <lance@illinois.edu>
2013-12-19 00:30         ` Payal Singh <payal@omniti.com>
2013-12-18 09:32 ` reiner peterke <zedaardv@gmail.com>

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