Re: Sort performance on large tables - Mailing list pgsql-performance

From Richard Huxton
Subject Re: Sort performance on large tables
Date
Msg-id 437088A1.8090304@archonet.com
Whole thread Raw
In response to Sort performance on large tables  (Charlie Savage <cfis@interserv.com>)
Responses Re: Sort performance on large tables
List 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

pgsql-performance by date:

Previous
From: Charlie Savage
Date:
Subject: Sort performance on large tables
Next
From: Mario Weilguni
Date:
Subject: Re: 8.1 iss