Re: Drawbacks of create index where is not null ?

From: Craig Ringer <ringerc(at)ringerc(dot)id(dot)au>
To: Franck Routier <franck(dot)routier(at)axege(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Drawbacks of create index where is not null ?
Date: 2012-10-11 05:26:03
Message-ID: 5076586B.1000306@ringerc.id.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Scott Marlowe 2012-10-11 05:36:05 Re: shared_buffers/effective_cache_size on 96GB server
Previous Message Craig Ringer 2012-10-11 04:38:45 Re: hash aggregation