pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Greg Stark <gsstark@mit.edu>
To: Tobias Brox <tobias@nordicbet.com>
Cc: Bruno Wolff III <bruno@wolff.to>
Cc: pgsql-performance@postgresql.org
Subject: Re: Index on a NULL-value
Date: 31 May 2005 00:21:25 -0400
Message-ID: <87mzqcvxdm.fsf@stark.xeocode.com> (raw)
In-Reply-To: <20050531034529.GJ26100@tobias.exoweb.net>
References: <20050531030207.GD26100@tobias.exoweb.net>
	<20050531032119.GH26100@tobias.exoweb.net>
	<20050531033633.GA20015@wolff.to>
	<20050531034529.GJ26100@tobias.exoweb.net>

Tobias Brox <tobias@nordicbet.com> writes:

> [Bruno Wolff III - Mon at 10:36:33PM -0500]
> > You want something like this:
> > CREATE INDEX b_is_null ON mock(b) WHERE b IS NULL;
> 
> Oh, cool.  I wasn't aware that this is possible.  This would probably help
> us a lot of places. :-)

Yeah it's a cool feature.

I'm not 100% sure but I think it still won't consider this index unless the
column being indexed is used in some indexable operation. So for example if
you had 

CREATE INDEX b_null on mock(other) WHERE b IS NULL;

and something like

 SELECT * FROM b WHERE b IS NULL ORDER BY other
or
 SELECT * FROM b where other > 0 AND b IS NULL

then it would be a candidate because the ORDER BY or the other > 0 make the
index look relevant. But I don't think (again I'm not 100% sure) that the
partial index WHERE clause is considered in picking which indexes to consider.

It *is* considered in evaluating which index is the best one to use and
whether it's better than a sequential scan. Just not in the initial choice of
which indexes to look at at all.

-- 
greg




view thread (12+ messages)  latest in thread

Message-ID: <87mzqcvxdm.fsf@stark.xeocode.com>
Permalink:  ../87mzqcvxdm.fsf@stark.xeocode.com/
Also on:    postgresql.org/message-id/87mzqcvxdm.fsf@stark.xeocode.com

 · 

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: gsstark@mit.edu, tobias@nordicbet.com, bruno@wolff.to
  Subject: Re: Index on a NULL-value
  In-Reply-To: <87mzqcvxdm.fsf@stark.xeocode.com>

* 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