pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jim C. Nasby <jnasby@pervasive.com>
Cc: Greg Stark <gsstark@mit.edu>
Cc: Cristian Prieto <cristian@clickdiario.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Any way to optimize GROUP BY queries?
Date: Tue, 20 Dec 2005 16:44:47 -0500
Message-ID: <6542.1135115087@sss.pgh.pa.us> (raw)
In-Reply-To: <20051220194710.GJ28771@pervasive.com>
References: <00d701c604c1$e6945d80$6500a8c0@gt.ClickDiario.local>
	<87wti0ak60.fsf@stark.xeocode.com>
	<20051220194710.GJ28771@pervasive.com>

"Jim C. Nasby" <jnasby@pervasive.com> writes:
> On Mon, Dec 19, 2005 at 03:47:35PM -0500, Greg Stark wrote:
>> Increase your work_mem (or sort_mem in older postgres versions), you can do
>> this for the server as a whole or just for this one session and set it back
>> after this one query. You can increase it up until it starts causing swapping
>> at which point it would be counter productive.

> Just remember that work_memory is per-operation, so it's easy to push
> the box into swapping if the workload increases. You didn't say how much
> memory you have, but I'd be careful if work_memory * max_connections
> gets very much larger than your total memory.

It's considered good practice to have a relatively small default
work_mem setting (in postgresql.conf), and then let individual sessions
push up the value locally with "SET work_mem" if they are going to
execute queries that need it.  This works well as long as you only have
one or a few such "heavy" sessions at a time.

			regards, tom lane



view thread (4+ messages)

Message-ID: <6542.1135115087@sss.pgh.pa.us>
Permalink:  ../6542.1135115087@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/6542.1135115087@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, jnasby@pervasive.com, gsstark@mit.edu, cristian@clickdiario.com
  Subject: Re: Any way to optimize GROUP BY queries?
  In-Reply-To: <6542.1135115087@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