Re: Backwards index scan

From: Greg Stark <gsstark(at)mit(dot)edu>
To: John Sidney-Woollett <johnsw(at)wardbrook(dot)com>
Cc: Carlos Oliva <carlos(at)pbsinet(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Backwards index scan
Date: 2006-06-06 21:48:12
Message-ID: 87zmgq7y77.fsf@stark.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


John Sidney-Woollett <johnsw(at)wardbrook(dot)com> writes:

> I don't think that null values are indexed - you'll probably need to coalesce
> your null data value to some value if you want it indexed.

That is most definitely not true for Postgres. NULL values are included in the
index.

However NULLs sort as greater than all values in Postgres. So when you sort
descending they'll appear *first*. If you sort ascending they'll appear last.

If you have any clauses like 'WHERE col > foo' then it will not be true for
NULL values of col regardless of what foo is and those records will be
dropped. This is true regardless of whether there's an index.

--
greg

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jim C. Nasby 2006-06-06 22:10:56 Re: [pgsql-advocacy] Me And My Database
Previous Message Nikolay Samokhvalov 2006-06-06 20:40:49 Re: COLLATE