Re: slow self-join query - Mailing list pgsql-performance

From Scott Marlowe
Subject Re: slow self-join query
Date
Msg-id CAOR=d=0g7YRkzzup_BYxOsO-1d-kea31jbMm1-yq4iRHULv-pQ@mail.gmail.com
Whole thread Raw
In response to Re: slow self-join query  (Robert Poor <rdpoor@gmail.com>)
List pgsql-performance
also also wik

On Sun, Mar 18, 2012 at 8:37 AM, Robert Poor <rdpoor@gmail.com> wrote:
> On Sat, Mar 17, 2012 at 23:07, Scott Marlowe <scott.marlowe@gmail.com>
> wrote:
>>
>> Yeah try setting [work_mem] to something absurd like 500MB and see if the
>> plan changes.
>
>
> Suweet!  Sorting now runs in-memory, and that makes a big difference, even
> when groveling over 1M records (under 12 seconds rather than 7 hours).
>  Results in
>
>    http://explain.depesz.com/s/hNO

Well that's better.  Test various sizes of work_mem to see what you
need, then maybe double it.  How many simultaneous connections do you
have to this db?  Different accounts?  Different apps?  While it might
be worth setting for a user or a db, it might or might not be a good
thing to set it to something like 512MB world-wide.  On servers with
hundreds to thousands of connections, 16 or 32MB is often all you'd
want to set it to, since it's additive across all active sorts in the
db.  A thousand users suddenly sorting 512MB in memory at once, can
take down your db server in seconds.

Still seems like it's doing a lot of work.

pgsql-performance by date:

Previous
From: Scott Marlowe
Date:
Subject: Re: slow self-join query
Next
From: Robert Poor
Date:
Subject: Re: slow self-join query