X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 2E6D29DC89F for ; Wed, 15 Feb 2006 21:53:02 -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 82844-01 for ; Wed, 15 Feb 2006 21:53:05 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from smtp.nildram.co.uk (smtp.nildram.co.uk [195.112.4.54]) by postgresql.org (Postfix) with ESMTP id 52E269DCC8D for ; Wed, 15 Feb 2006 21:52:59 -0400 (AST) Received: from [192.168.0.5] (unknown [84.12.26.47]) by smtp.nildram.co.uk (Postfix) with ESMTP id BE51E2520EF; Thu, 16 Feb 2006 01:52:17 +0000 (GMT) Subject: Re: Strange Create Index behaviour From: Simon Riggs To: Gary Doades Cc: pgsql-performance@postgresql.org In-Reply-To: <43F38867.6010701@gpdnet.co.uk> References: <43F38867.6010701@gpdnet.co.uk> Content-Type: text/plain Date: Thu, 16 Feb 2006 01:52:09 +0000 Message-Id: <1140054729.12131.225.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.2.3 (2.2.3-2.fc4) Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.086 required=5 tests=[AWL=0.086] X-Spam-Score: 0.086 X-Spam-Level: X-Archive-Number: 200602/235 X-Sequence-Number: 17221 On Wed, 2006-02-15 at 20:00 +0000, Gary Doades wrote: > I have put together a test case that demonstrates the problem (see > below). I create a simple table, as close in structure to one of my > problem tables and populate an integer column with 100,000 zeros follow > by 100,000 random integers between 0 and 100,000. Then create an index > on this column. I then drop the table and repeat. The create index > should take around 1-2 seconds. A fair proportion of the time it takes > 50 seconds!!! > > If I fill the same row with all random data the create index always > takes a second or two. If I fill the column with all zeros everything is > still OK. Aside from the importance of investigating sort behaviour, have you tried to build a partial index WHERE col > 0 ? That way you wouldn't even be indexing the zeros. Best Regards, Simon Riggs