Re: Indexing null dates

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: johnsw(at)wardbrook(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Indexing null dates
Date: 2004-04-16 15:54:03
Message-ID: 29801.1082130843@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"John Sidney-Woollett" <johnsw(at)wardbrook(dot)com> writes:
> [ needs to make this fast: ]
> -- locate the next order
> select WCCustOrderID into vCustOrderID
> from CUSTOMER.WCCustOrderStatusLog
> where WCOrderStatusID = pStatusID
> and Acknowledged is null
> and Processing is null
> for update
> limit 1;

> My question is whether postgres can index null values, and if not, do I
> have to accept a full table scan when locating records.

It indexes them, but "is null" is not an indexable operator, so you
can't directly solve the above with a 3-column index. What you can do
instead is use a partial index, for instance

create index i on CUSTOMER.WCCustOrderStatusLog (WCOrderStatusID)
where Acknowledged is null and Processing is null;

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-04-16 16:11:50 Re: Locale support on Mac OS X
Previous Message Uwe C. Schroeder 2004-04-16 15:44:22 Re: A simple question about Read committed isolation level