Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TMBHe-00044o-Dc for pgsql-performance@postgresql.org; Thu, 11 Oct 2012 05:26:10 +0000 Received: from mail-da0-f46.google.com ([209.85.210.46]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TMBHc-0002oP-VL for pgsql-performance@postgresql.org; Thu, 11 Oct 2012 05:26:09 +0000 Received: by mail-da0-f46.google.com with SMTP id n41so561708dak.19 for ; Wed, 10 Oct 2012 22:26:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=HRu7viOcFlS2OIXus/lIIXHdUD3+nZ5HXYH8hWLxTJc=; b=iWM71Mobj+JcSe+H44Gyoi7aDkoj3XCCumRtxucCVIY9eSZL/sMNgw4gHEPtkjHqah e1A1ve+mU0zA13oKuqK26jLd62QxKpGmshte8rf99qJUzt/KYms7gG1pgwbuVrVwIzpO 9W21vIpMEicM/I3SmR6l2pnrxcYQt4FyuqoFrC0+ICyS5tltIEj716+7UyaBRvoXjEow IBvMM4EXCtY1Dasn3IXFE4eg8HwmZXBfAvyJyM0yY/UY8t7B23vMFTgmj2tk0qWj3i5R RCOqs53cMbshFFV4K3RzHrwrXjnkXxFp7bNZF3Df7QjrrLED3umU15PLjYigtwsYjnHK Hn+A== Received: by 10.68.225.34 with SMTP id rh2mr289080pbc.78.1349933168040; Wed, 10 Oct 2012 22:26:08 -0700 (PDT) Received: from ayaki.localdomain (office1.postnewspapers.com.au. [150.101.171.128]) by mx.google.com with ESMTPS id tw2sm967883pbc.34.2012.10.10.22.26.05 (version=SSLv3 cipher=OTHER); Wed, 10 Oct 2012 22:26:07 -0700 (PDT) Message-ID: <5076586B.1000306@ringerc.id.au> Date: Thu, 11 Oct 2012 13:26:03 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120717 Thunderbird/14.0 MIME-Version: 1.0 To: Franck Routier CC: pgsql-performance@postgresql.org Subject: Re: Drawbacks of create index where is not null ? References: <5075AB0F.5030005@axege.com> In-Reply-To: <5075AB0F.5030005@axege.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQng0zWOfHSCoFdVn3XYMwKo2dAPtxDI2jnhBQcLsAHoMvWeZ/qVbx5pDD11cFNclT9t1Sgq X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201210/141 X-Sequence-Number: 48100 On 10/11/2012 01:06 AM, Franck Routier wrote: > Hi, > > I have pretty large tables, with columns that might never receive any > data, or always receive data, based on the customer needs. > The index on these columns are really big, even if the column is never > used, so I tend to add a "where col is not null" clause on those indexes. > > What are the drawbacks of defining my index with a "where col is not > null" clause ? * You can't CLUSTER on a partial index; and * The partial index will only be used for queries that use the condition "WHERE col IS NOT NULL" themselves. The planner isn't super-smart about how it matches index WHERE conditions to query WHERE conditions, so you'll want to use exactly the same condition text where possible. -- Craig Ringer