Re: does the query planner consider work_mem? - Mailing list pgsql-performance

From Tom Lane
Subject Re: does the query planner consider work_mem?
Date
Msg-id 25585.1338563709@sss.pgh.pa.us
Whole thread Raw
In response to Re: does the query planner consider work_mem?  (Murat Tasan <mmuurr@gmail.com>)
List pgsql-performance
Murat Tasan <mmuurr@gmail.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

pgsql-performance by date:

Previous
From: Tom Lane
Date:
Subject: Re: Select from sequence in slow query log
Next
From: Maciek Sakrejda
Date:
Subject: Re: Trouble with plan statistics for behaviour for query.