Re: ORDER BY and NULLs - Mailing list pgsql-sql

From T E Schmitz
Subject Re: ORDER BY and NULLs
Date
Msg-id 414DEA7F.6050100@numerixtechnology.de
Whole thread Raw
In response to Re: ORDER BY and NULLs  (Greg Stark <gsstark@mit.edu>)
Responses Re: ORDER BY and NULLs  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
Hello Greg,

Greg Stark wrote:

> T E Schmitz <mailreg@numerixtechnology.de> writes:
> 
>>Quote: "PostgreSQL will not index NULL values. Because an index will never
>>include NULL values, it cannot be used to satisfy the ORDER BY clause of a
>>query that returns all rows in a table."
> 
> 
> You should just cross out that whole section. It's just flatly wrong. 
> I had always assumed it was just people bringing assumptions over from Oracle
> where it is true. Perhaps this book is to blame for some of the confusion.
> Which book is it?

PostgreSQL by Korry Douglas + Susan Douglas, ISBN 0-7357-1257-3; Feb 2003

> Postgres indexes NULLs. It can use them for ORDER BY clauses. 
> 
> Where it cannot use them is to satisfy "WHERE foo IS NULL" or "WHERE foo IS
> NOT NULL" constraints though. That's an implementation detail, but it can be
> worked around with partial indexes.

The paragraph continues:
"If the SELECT command included the clause WHERE phone NOT NULL, 
PostgreSQL could use the index to satisfy the ORDER BY clause.
An index that covers optional (NOT NULL) columns will not be used to 
speed table joins either."

-- 

Regards/Gruß,

Tarlika Elisabeth Schmitz


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: ORDER BY and NULLs
Next
From: Tom Lane
Date:
Subject: Re: ORDER BY and NULLs