Re: work_mem = 900MB but Sort Method: external merge Disk: 304008kB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Reid(dot)Thompson(at)ateb(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: work_mem = 900MB but Sort Method: external merge Disk: 304008kB
Date: 2011-02-22 17:06:14
Message-ID: 1936.1298394374@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Reid Thompson <Reid(dot)Thompson(at)ateb(dot)com> writes:
> What am I missing that causes this to resort to sorting on disk?

The in-memory space required to sort N tuples can be significantly
larger than the on-disk space, because the latter representation is
optimized to be small and the in-memory representation not so much.
I haven't seen a 3X differential before, but it's not outside the realm
of reason, especially for narrow rows like these where it's all about
the overhead. I suspect if you crank work_mem up still more, you'll see
it switch over. It flips to on-disk sort when the in-memory
representation exceeds the limit ...

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Vick Khera 2011-02-22 17:08:09 Re: Covert database from ASCII to UTF-8
Previous Message Vibhor Kumar 2011-02-22 17:03:38 Re: Covert database from ASCII to UTF-8