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

2016-04-14 Thread Alban Hertroys
> On 14 Apr 2016, at 15:12, Thomas Kellerer wrote: > > now() (and current_timestamp as well) are defined to return the > same value throughout the entire transaction. > > So the optimizer _should_ be smart enough to do the conversion only > once at the beginning of the

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

2016-04-13 Thread Alban Hertroys
On 13 April 2016 at 15:45, Tom Lane wrote: > Thomas Kellerer writes: >> 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

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

2016-04-13 Thread Tom Lane
Thomas Kellerer writes: > 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.

[GENERAL] Why is the comparison between timestamp and date so much slower then between two dates

2016-04-13 Thread Thomas Kellerer
I came across something strange today. Consider the following table: CREATE TABLE price_history ( product_id integer, valid_from date, valid_to date, price integer ); CREATE INDEX i1 ON price_history (product_id, valid_from, valid_to); The table