Re: Why is the comparison between timestamp and date so much slower then between two dates

Поиск
Список
Период
Сортировка
От Thomas Kellerer
Тема Re: Why is the comparison between timestamp and date so much slower then between two dates
Дата
Msg-id nendou$sq1$1@ger.gmane.org
обсуждение исходный текст
Ответ на Re: Why is the comparison between timestamp and date so much slower then between two dates  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Tom Lane schrieb am 13.04.2016 um 15:45:
>> So my question is: why is comparing a timestamp to a date so much slower?
>
> The date has to be up-converted to a timestamptz (not timestamp).
> I think the expensive part of that is determining what timezone
> applies, in particular whether DST is active.  You could try it
> with "localtimestamp" (no parens) instead of "now()" to see how
> it performs with a non-tz timestamp.

localtimestamp is indeed faster then now(), but still a bit slower then
current_date (700ms vs 500ms after 5 runs for each)

But as the value of now() won't change throughout the runtime of the statement
(actually the transaction), I wonder why it is being converted for every row.

Thomas

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

Предыдущее
От: Craig Ringer
Дата:
Сообщение: Re: Multimaster
Следующее
От: Thomas Kellerer
Дата:
Сообщение: Re: Why is the comparison between timestamp and date so much slower then between two dates