Re: BUG #4748: hash join and sort-merge join make different results

From: Roman Kononov <kononov(at)ftml(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4748: hash join and sort-merge join make different results
Date: 2009-04-04 05:13:54
Message-ID: 49D6EC92.1090609@ftml.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 2009-04-03 23:32 Tom Lane said the following:
> Roman Kononov <kononov(at)ftml(dot)net> writes:
>> On 2009-04-03 14:57 Tom Lane said the following:
>>> I think we could fix this by having interval_hash() duplicate the
>>> total-span calculation done by interval_cmp_internal, and then return
>>> the hash of the resulting TimeOffset. This is going to break existing
>>> hash indexes on intervals, but there seems little choice...
>
>> Consider hashing the result of justify_interval().
>
> Uh, what's your point? We have to match interval_eq, not
> justify_interval.

For any two intervals a and b, saying that interval_cmp_interval(a,b)==0
is exactly the same as saying that (aj.month==bj.month && aj.day==bj.day
&& aj.time==bj.time), where aj=justify_interval(a) and
bj=justify_interval(b). Therefore, instead of hashing
interval_cmp_value() you can hash justify_interval(), where
interval_cmp_value() is the transformation of intervals in
interval_cmp_interval().

You said that hashing interval_cmp_value() breaks existing hash indexes.
Hashing "justified" intervals avoids such breaking in some cases.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2009-04-04 05:25:02 Re: BUG #4748: hash join and sort-merge join make different results
Previous Message Tom Lane 2009-04-04 05:02:32 Re: BUG #4748: hash join and sort-merge join make different results