Re: Type casting and indexes

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Type casting and indexes
Дата
Msg-id 20978.1052411107@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Type casting and indexes  ("David Olbersen" <DOlbersen@stbernard.com>)
Список pgsql-performance
"David Olbersen" <DOlbersen@stbernard.com> writes:
> So it seems that the type conversion is killing the use of the index, even though the type conversion has to happen
forthe condition to be tested. 

Seems like I just answered this yesterday ;-)

Note the difference in the number of estimated rows in the two explains.
The reason is that the timestamptz conversion is not a constant and so
the planner can't get a good estimate of the number of rows that will
satisfy it.  (And the reason it's not a constant is that it depends on
SET TIMEZONE.)

Bottom line: declare the constant correctly.  Or at least don't
gratuitously cast it to the wrong thing.

            regards, tom lane


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

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: Type casting and indexes
Следующее
От: "scott.marlowe"
Дата:
Сообщение: Re: [SQL] Unanswered Questions WAS: An unresolved performance