pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Shaun Thomas <sthomas@peak6.com>
To: Scott Marlowe <scott.marlowe@gmail.com>
Cc: Greg Smith <greg@2ndquadrant.com>
Cc: felix <crucialfelix@gmail.com>
Cc: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Subject: Re: Really really slow select count(*)
Date: Fri, 4 Feb 2011 13:14:14 -0600
Message-ID: <4D4C5006.7030805@peak6.com> (raw)
In-Reply-To: <AANLkTi=NAyNcmhMX5J3X5q2R7KgAO1XkTX=Afue_XZaN@mail.gmail.com>
References: <AANLkTinAJcm5A+i1O_R87aiYyu8N2OWgoaL9RfR=tUR9@mail.gmail.com>
	<4D4C138C.7010304@2ndquadrant.com>
	<4D4C1555.40209@peak6.com>
	<AANLkTikrS5JkJDMjAXpcRWRnuLbX+MHB=CWb_mFa9qb-@mail.gmail.com>
	<4D4C2AC3.5020804@peak6.com>
	<AANLkTikN75hcCL5Nhgh8Z9c7ZLtduMdjsn07BgO_D_yZ@mail.gmail.com>
	<AANLkTikpH2ws_iiyqNE-o-TWB0-5pMbrS0V5SymXBo2X@mail.gmail.com>
	<AANLkTi=3n_W-OFVuVHx3Tthn_KiMN42BturJUS5BuWVz@mail.gmail.com>
	<4D4C3BCA.5010808@peak6.com>
	<AANLkTikjw46g=VD5vbkOfDz93JMX7vBijj7dTEs+LN4U@mail.gmail.com>
	<4D4C478D.9070909@2ndquadrant.com>
	<AANLkTi=NAyNcmhMX5J3X5q2R7KgAO1XkTX=Afue_XZaN@mail.gmail.com>

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



view thread (66+ messages)  latest in thread

Message-ID: <4D4C5006.7030805@peak6.com>
Permalink:  ../4D4C5006.7030805@peak6.com/
Also on:    postgresql.org/message-id/4D4C5006.7030805@peak6.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: sthomas@peak6.com, scott.marlowe@gmail.com, greg@2ndquadrant.com, crucialfelix@gmail.com
  Subject: Re: Really really slow select count(*)
  In-Reply-To: <4D4C5006.7030805@peak6.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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