On 02/04/2011 01:01 PM, Scott Marlowe wrote:

begin;
select * into temporaryholdingtable order by somefield;
truncate oldtable;
insert into oldtables select * from temporaryholdingtable;
commit;

That's usually how I do it, except for larger tables, I also throw in a DROP INDEX for all the indexes on the table before the insert, and CREATE INDEX statements afterwards.

Which actually brings up a question I've been wondering to myself that I may submit to [HACKERS]: Can we add a a parallel option to the reindexdb command? We added one to pg_restore, so we already know it works.

I have a bunch of scripts that get all the indexes in the database and order them by size (so they're distributed evenly), round-robin them into separate REINDEX sql files, and launches them all in parallel depending on how many threads you want, but that's so hacky I feel dirty every time I use it.

--
Shaun Thomas
OptionsHouse | 141 W. Jackson Blvd. | Suite 800 | Chicago IL, 60604
312-676-8870
stho...@peak6.com

______________________________________________

See  http://www.peak6.com/email_disclaimer.php
for terms and conditions related to this email

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

Reply via email to