Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
> > 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."
>
> My goodness, it seems to be a veritable fount of misinformation :-(
>
> I wonder how much of this is stuff that is true for Oracle and they just
> assumed it carried over?
The first part is true for Oracle. You have to add the WHERE phone NOT NULL to
convince Oracle it can use an index. Or just make the column NOT NULL to begin
with I think.
However as far as I recall the second part is not true. Oracle is smart enough
to realize that an equijoin clause implies NOT NULL and therefore allows it to
use the index.
(This may have all changed in Oracle 9+. The last I saw of Oracle was 8i)
I wonder if they just tried explain on a bunch of queries and noticed that
postgres wasn't using an index for SELECT * FROM foo ORDER BY bar and came up
with explanations for the patterns they saw?
--
greg