Re: Sort performance on large tables

From: Richard Huxton <dev(at)archonet(dot)com>
To: Charlie Savage <cfis(at)interserv(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Sort performance on large tables
Date: 2005-11-08 11:14:41
Message-ID: 437088A1.8090304@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Charlie Savage wrote:
> Hi everyone,
>
> I have a question about the performance of sort.

> Note it takes over 10 times longer to do the sort than the full
> sequential scan.
>
> Should I expect results like this? I realize that the computer is quite
> low-end and is very IO bound for this query, but I'm still surprised
> that the sort operation takes so long.

The sort will be spilling to disk, which will grind your I/O to a halt.

> work_mem = 16384 # in Kb

Try upping this. You should be able to issue "set work_mem = 100000"
before running your query IIRC. That should let PG do its sorting in
larger chunks.

Also, if your most common access pattern is ordered via tlid look into
clustering the table on that.
--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Marc Morin 2005-11-08 13:19:44 Re: Sort performance on large tables
Previous Message Mario Weilguni 2005-11-08 10:34:19 Re: 8.1 iss