pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Josh Berkus <josh@agliodbs.com>
Cc: Jeffrey W. Baker <jwbaker@acm.org>
Cc: Ron Peacetree <rjpeace@earthlink.net>
Cc: pgsql-hackers@postgresql.org
Cc: pgsql-performance@postgresql.org
Subject: Re: [HACKERS] A Better External Sort?
Date: Sat, 01 Oct 2005 11:44:15 -0400
Message-ID: <8643.1128181455@sss.pgh.pa.us> (raw)
In-Reply-To: <433C1C2D.7090908@agliodbs.com>
References: <21402654.1127923414088.JavaMail.root@elwamui-polski.atl.sa.earthlink.net>
	<1127968040.8954.12.camel@noodles>
	<433C1C2D.7090908@agliodbs.com>

Josh Berkus <josh@agliodbs.com> writes:
> The biggest single area where I see PostgreSQL external sort sucking is 
>   on index creation on large tables.   For example, for free version of 
> TPCH, it takes only 1.5 hours to load a 60GB Lineitem table on OSDL's 
> hardware, but over 3 hours to create each index on that table.  This 
> means that over all our load into TPCH takes 4 times as long to create 
> the indexes as it did to bulk load the data.
> ...
> Following an index creation, we see that 95% of the time required is the 
> external sort, which averages 2mb/s.  This is with seperate drives for 
> the WAL, the pg_tmp, the table and the index.  I've confirmed that 
> increasing work_mem beyond a small minimum (around 128mb) had no benefit 
> on the overall index creation speed.

These numbers don't seem to add up.  You have not provided any details
about the index key datatypes or sizes, but I'll take a guess that the
raw data for each index is somewhere around 10GB.  The theory says that
the runs created during the first pass should on average be about twice
work_mem, so at 128mb work_mem there should be around 40 runs to be
merged, which would take probably three passes with six-way merging.
Raising work_mem to a gig should result in about five runs, needing only
one pass, which is really going to be as good as it gets.  If you could
not see any difference then I see little hope for the idea that reducing
the number of merge passes will help.

Umm ... you were raising maintenance_work_mem, I trust, not work_mem?

We really need to get some hard data about what's going on here.  The
sort code doesn't report any internal statistics at the moment, but it
would not be hard to whack together a patch that reports useful info
in the form of NOTICE messages or some such.

			regards, tom lane



view thread (112+ messages)  latest in thread

Message-ID: <8643.1128181455@sss.pgh.pa.us>
Permalink:  ../8643.1128181455@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/8643.1128181455@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, josh@agliodbs.com, jwbaker@acm.org, rjpeace@earthlink.net, pgsql-hackers@postgresql.org
  Subject: Re: [HACKERS] A Better External Sort?
  In-Reply-To: <8643.1128181455@sss.pgh.pa.us>

* 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