Re: Really really slow select count(*)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
sthomas@xxxxxxxxx

______________________________________________

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

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


[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux