Re: Index not used with IS NULL

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Index not used with IS NULL
Дата
Msg-id 28129.1045418622@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Index not used with IS NULL  (Dima Tkach <dmitry@openratings.com>)
Ответы Re: Index not used with IS NULL
Re: Index not used with IS NULL
Список pgsql-general
Dima Tkach <dmitry@openratings.com> writes:
> Tom, as you said in your message "we do index nulls" - why do you index
> them, if there is no way to use those index values? :-)

So that an indexscan can be a substitute for seqscan + sort.

Also, in a multi-column index you must be prepared to index nulls,
or you won't correctly answer questions that look at only some of the
columns.

Index types that don't support ordered scans don't have to store nulls
(at least in their first column) and indeed rtree and gist do not.  I
forget whether hash does.

> A row in the table is a tree node. A node can have one parent, ot no
> parent at all.

You're better off making the root node link to itself (compare handling
of /.. in a Unix filesystem).  NULL parent link does not mean "has no
parent", it means "parent is unknown".

            regards, tom lane

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

Предыдущее
От: Doug McNaught
Дата:
Сообщение: Re: Question on 'create domain'
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: Index not used with IS NULL