X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id F04B29DC828 for ; Thu, 16 Mar 2006 16:41:06 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 12325-02 for ; Thu, 16 Mar 2006 16:41:07 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 5BBD89DCCB4 for ; Thu, 16 Mar 2006 16:41:02 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id k2GKf3s4019993; Thu, 16 Mar 2006 15:41:03 -0500 (EST) To: Jerry Sievers cc: pgsql-admin@postgresql.org Subject: Re: Curious run-away index build on upgrade to 8.1.3 In-reply-to: References: <16725.1142523155@sss.pgh.pa.us> <18502.1142533042@sss.pgh.pa.us> Comments: In-reply-to Jerry Sievers message dated "16 Mar 2006 13:51:12 -0500" Date: Thu, 16 Mar 2006 15:41:03 -0500 Message-ID: <19992.1142541663@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.113 required=5 tests=[AWL=0.113] X-Spam-Score: 0.113 X-Spam-Level: X-Archive-Number: 200603/140 X-Sequence-Number: 20897 Jerry Sievers writes: > Tom Lane writes: >> What I still don't understand though is why you see it >> in 8.1 and not 8.0 ... the src/port/qsort.c code didn't change at all >> between those versions. Maybe 8.0 isn't taking the qsort code path, >> perhaps because it uses a shade more memory or some such. Could you >> try increasing maintenance_work_mem even more, like to 100M, >> and see if 8.0 gets slow? > I did as you suggest here; taking the MWM setting incrementally up to > nearly a Gig in 100M increments, also raised and lowered the work_mem > setting too. > Tried a dozen or more combos and in every case, the index built > quickly on 8.0.3. On further analysis, it seems the problem is dependent on the exact ordering of the inputs to the qsort function. So not only do you need maintenance_work_mem to be large enough that the code will try to use qsort, but the physical order of the rows in the table matters. I suspect that you are testing on an 8.0 table with a different physical row order --- if you drop the table and reload it from the same dump you loaded into 8.1, does it get slow? regards, tom lane