pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Allen Landsidel <all@biosys.net>
To: Josh Berkus <josh@agliodbs.com>
To: pgsql-performance@postgresql.org
Subject: Re: index creation order?
Date: Fri, 31 Oct 2003 13:27:12 -0500
Message-ID: <6.0.0.22.0.20031031131506.024864b0@pop.hotpop.com> (raw)
In-Reply-To: <200310310910.30504.josh@agliodbs.com>
References: <6.0.0.22.0.20031031104214.024853b0@pop.hotpop.com>
	<200310310910.30504.josh@agliodbs.com>

At 12:10 10/31/2003, Josh Berkus wrote:
>Allen,
>
> > a) CREATE TABLE with no indexes or keys.  Run the COPY (fast, ~30min), then
> > CREATE INDEX on each column it's needed on, and ALTER TABLE for the pk and
> > each fk needed.
>
>Did you ANALYZE after the copy?

No, and this was my major mistake.  I normally run analyze periodically 
from cron, anywhere from once an hour to ever 15 minutes depending on the 
db.. I had disabled that for this because I didn't want anything competing 
with this stuff for disk I/O.

I followed your other suggestions as well, canceled the index that was 
running, analyzed the whole db, and ran the queries again.  All of them are 
running in under 10 or so minutes after the analyze.

I'll just be adding the PKs and the Indexes, I can add triggers/rules of my 
own for the RI, rather than worry about FK creation screwing up.

I had no idea analyze was playing such a big role in this sense.. I really 
thought that other than saving space, it wasn't doing much for tables that 
don't have indexes on the.

Thanks for the help.

> > shared_buffers = 30000
>hmmm ... 236MB ....
> > max_fsm_pages = 2000000
>2MB, fine ...
> > wal_buffers = 128
>1MB, also fine ...
> > sort_mem = 1310720 (1.2GB)
>Problem here.   As documented everywhere, sort_mem is allocated *per sort* 
>not
>per query, user, or shared.   This means that if the "add PK" operation
>involves 2 or more sorts (not sure, haven't tested it), then you're
>allocating .7GB RAM more than you acutally have.  This may be the cause of
>your problem, particularly if *anything* is going on concurrent to the load.

I didn't know this was per-sort per-backend, I thought it was per-backend 
for all sorts running on that backend.  I've dropped it down to 256MB.

> > checkpoint_segments = 64
>IF you have the disk space (+ 2GB) I'd raise this to 150-300 during the load
>operation.

Done, at 128, which seems to be enough for now.  I'll fiddle more with this 
later on.

> > commit_delay = 20000
> > commit_siblings = 2
>These settings are for heavy multi-user update activity. They are not useful
>for a single-user load, and may even lower performance.

That's what's going on.. this database I'm working on isn't the only one in 
the system, and some things are using different schemas in the database I'm 
working on, so this isn't something I can afford to turn off.  Most of the 
activity is heavy and transient.. many INSERT/UPDATE/DELETE cycles.

Again, thanks for the help, I really do appreciate it.  It's gratifying and 
depressing to know the last two or so days work could've been compressed 
into 3 hours if I'd just run that damn analyze. ;)






view thread (11+ messages)  latest in thread

Message-ID: <6.0.0.22.0.20031031131506.024864b0@pop.hotpop.com>
Permalink:  ../6.0.0.22.0.20031031131506.024864b0@pop.hotpop.com/
Also on:    postgresql.org/message-id/6.0.0.22.0.20031031131506.024864b0@pop.hotpop.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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: all@biosys.net, josh@agliodbs.com
  Subject: Re: index creation order?
  In-Reply-To: <6.0.0.22.0.20031031131506.024864b0@pop.hotpop.com>
  References: <6.0.0.22.0.20031031104214.024853b0@pop.hotpop.com> <200310310910.30504.josh@agliodbs.com> <6.0.0.22.0.20031031131506.024864b0@pop.hotpop.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