Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id B53212E008B for ; Thu, 22 May 2008 16:18:15 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 84305-02-9 for ; Thu, 22 May 2008 16:18:06 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by developer.postgresql.org (Postfix) with ESMTP id A127D2E0097 for ; Thu, 22 May 2008 16:18:03 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m4MJI1hu003607; Thu, 22 May 2008 15:18:01 -0400 (EDT) To: "Guillaume Smet" cc: pgsql-performance Subject: Re: Index creation time and distribution In-reply-to: <1d4e0c10805220638x64f80609ob9a6fe00e4587362@mail.gmail.com> References: <1d4e0c10805220532v514c2bd5je4c6c20ceb485495@mail.gmail.com> <29529.1211462076@sss.pgh.pa.us> <1d4e0c10805220638x64f80609ob9a6fe00e4587362@mail.gmail.com> Comments: In-reply-to "Guillaume Smet" message dated "Thu, 22 May 2008 15:38:25 +0200" Date: Thu, 22 May 2008 15:18:00 -0400 Message-ID: <3606.1211483880@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/309 X-Sequence-Number: 30277 "Guillaume Smet" writes: > On Thu, May 22, 2008 at 3:14 PM, Tom Lane wrote: >> Do you have maintenance_work_mem set large enough that the index >> creation sort is done in-memory? 8.1 depends on the platform's qsort >> and a lot of them are kinda pessimal for input like this. > maintenance_work_mem is set to 256 MB and the size of the index is 400 MB. > Should I try to raise it up to 512 MB? The server only has 2GB of RAM > so it seems a bit high. Hmm, that's most likely not going to be enough to get it to do an in-memory sort ... try turning on trace_sort to see. But anyway, if you are in the on-disk sort regime, 8.3 is only going to be marginally faster for such a case --- it's going to have to write all the index entries out and read 'em back in anyway. >> 8.2 (which uses our own qsort) seems to perform better in a quick >> test. > Mmmmh OK. I was considering an upgrade to 8.3 in the next months anyway. > Do we agree that in the case of unnamed prepared statement, 8.3 plans > the query after the BIND? The partial index seems to be a better > solution anyway, considering that it's 12 MB vs 400 MB. Ermm .. this is in fact mostly broken in 8.3.0 and 8.3.1. If you don't want to wait for 8.3.2, you need this patch: http://archives.postgresql.org/pgsql-committers/2008-03/msg00566.php regards, tom lane