pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Simon Riggs <simon@2ndquadrant.com>
To: Markus Schaber <schabi@logix-tt.com>
Cc: PostgreSQL Performance List <pgsql-performance@postgresql.org>
Subject: Re: PostgreSQL underestimates sorting
Date: Thu, 23 Nov 2006 15:20:35 +0000
Message-ID: <1164295236.3841.629.camel@silverbirch.site> (raw)
In-Reply-To: <456423B3.7010505@logix-tt.com>
References: <456423B3.7010505@logix-tt.com>

On Wed, 2006-11-22 at 11:17 +0100, Markus Schaber wrote:

> PostgreSQL 8.1 (and, back then, 7.4) have the tendency to underestimate
> the costs of sort operations, compared to index scans.
> 
> The Backend allocates gigs of memory (we've set sort_mem to 1 gig), and
> then starts spilling out more Gigs of temporary data to the disk. So the
> execution gets - in the end - much slower compared to an index scan, and
> wastes lots of disk space.
> 
> We did not manage to tune the config values appropriately, at least not
> without causing other query plans to suffer badly.

8.2 has substantial changes to sort code, so you may want to give the
beta version a try to check for how much better it works. That's another
way of saying that sort in 8.1 and before has some performance problems
when you are sorting more than 6 * 2 * work_mem (on randomly sorted
data) and the cost model doesn't get this right, as you observe.

Try enabling trace_sort (available in both 8.1 and 8.2) and post the
results here please, which would be very useful to have results on such
a large real-world sort.

-- 
  Simon Riggs             
  EnterpriseDB   http://www.enterprisedb.com





view thread (6+ messages)

Message-ID: <1164295236.3841.629.camel@silverbirch.site>
Permalink:  ../1164295236.3841.629.camel@silverbirch.site/
Also on:    postgresql.org/message-id/1164295236.3841.629.camel@silverbirch.site

 · 

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: simon@2ndquadrant.com, schabi@logix-tt.com
  Subject: Re: PostgreSQL underestimates sorting
  In-Reply-To: <1164295236.3841.629.camel@silverbirch.site>

* 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