pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Craig Ringer <ringerc@ringerc.id.au>
To: Franck Routier <franck.routier@axege.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Drawbacks of create index where is not null ?
Date: Thu, 11 Oct 2012 13:26:03 +0800
Message-ID: <5076586B.1000306@ringerc.id.au> (raw)
In-Reply-To: <5075AB0F.5030005@axege.com>
References: <5075AB0F.5030005@axege.com>

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




view thread (6+ messages)  latest in thread

Message-ID: <5076586B.1000306@ringerc.id.au>
Permalink:  ../5076586B.1000306@ringerc.id.au/
Also on:    postgresql.org/message-id/5076586B.1000306@ringerc.id.au

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: ringerc@ringerc.id.au, franck.routier@axege.com
  Subject: Re: Drawbacks of create index where is not null ?
  In-Reply-To: <5076586B.1000306@ringerc.id.au>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox