Re: ORDER BY and NULLs

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: ORDER BY and NULLs
Дата
Msg-id 874qltkbjc.fsf@stark.xeocode.com
обсуждение исходный текст
Ответ на Re: ORDER BY and NULLs  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: ORDER BY and NULLs
Список pgsql-sql
Tom Lane <tgl@sss.pgh.pa.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



В списке pgsql-sql по дате отправления:

Предыдущее
От: Worik
Дата:
Сообщение: Re: How to check postgres running or not ?
Следующее
От: Worik
Дата:
Сообщение: Re: How to check postgres running or not ?