Re: Really really slow select count(*) - Mailing list pgsql-performance

From Shaun Thomas
Subject Re: Really really slow select count(*)
Date
Msg-id 4D4C5006.7030805@peak6.com
Whole thread Raw
In response to Re: Really really slow select count(*)  (Scott Marlowe <scott.marlowe@gmail.com>)
List pgsql-performance
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@peak6.com

______________________________________________

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

pgsql-performance by date:

Previous
From: Josh Berkus
Date:
Subject: Write-heavy pg_stats_collector on mostly idle server
Next
From: felix
Date:
Subject: Re: Really really slow select count(*)