Re: does the query planner consider work_mem?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Murat Tasan <mmuurr(at)gmail(dot)com>
Cc: Ants Aasma <ants(at)cybertec(dot)at>, pgsql-performance(at)postgresql(dot)org
Subject: Re: does the query planner consider work_mem?
Date: 2012-06-01 15:15:09
Message-ID: 25585.1338563709@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Murat Tasan <mmuurr(at)gmail(dot)com> writes:
> p.s. on the 8.4 version EXPLAIN ANALYZE *still* tells me that an
> external merge on disk is happening, despite my setting of work_mem to
> a full 16 MB this time.

When we have to push sort data to disk, it's written in a form that's
noticeably more compact than what's used in-memory. So it can be
expected that an in-memory sort will need significantly more memory
than what an external merge reports using on-disk. I'd try cranking
up work_mem to at least 10X the on-disk size if you want to be sure
of seeing an in-memory sort.

However, so far as I can see the sort is taking much less time than
the scan and join steps anyway, so you're not likely to get much
improvement this way. The unstable performance is a result of caching
effects for the table data, not of how the sort is done.

regards, tom lane

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Maciek Sakrejda 2012-06-01 15:38:10 Re: Trouble with plan statistics for behaviour for query.
Previous Message Tom Lane 2012-06-01 13:47:53 Re: Select from sequence in slow query log